Name a Day Mon|Tue|Wed and Get Date in Previous Week

Posted by jonathan on October 18, 2006

I use this command-line UNIX utility for generating filenames when I know that a, sayyy, audio stream was generated in the previous week, but I only know the day …

Usage: `datep sun`
prints: 20061015 which in this case is a couple days previous to the current day. Perfect for when you want a filename friendly date from yesterday or before.

This may be backticked into any other command for generating filenames, etc. Use at your own-risk. Use ‘View source’ in your browser to get the source.

#include 
#include 
#include 

int main (int argc, const char * argv[]) {

# ifdef _DEBUG
	// Print args 0 - command, 1 - 3 letter day
	int i = 0;
	for( i=0 ; i