DATE.sml

  Download

More scripts: SML Fundamentals

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# DATE.sml
# Example of user-defined function defined to return a string
numeric date = 20090801;
# function to convert date number YYYYYMMDDD
# to string MM/DD/YYYY
func string convertDate(numeric datenum){
	local string date$, mon$, day$, yr$;
	date$ = sprintf("%d", datenum);
	yr$ = date$.substr(0, 4);
	mon$ = date$.substr(4, 2);
	day$ = date$.substr(6, 2);
	date$ = sprintf("%s/%s/%s", mon$, day$, yr$);
	return date$;
	}
clear();
print( convertDate(date) );