Conv-ISO Date

From Vectorlab
Jump to: navigation, search


Function ISOdate converts the system date into ISO-format yyyy-mm-dd. By Petri Sakkinen

{ Function ISOdate converts the system date into ISO-format yyyy-mm-dd }
{ © Petri Sakkinen 2009 }
FUNCTION ISOdate (theDate : STRING) : STRING;
VAR
	theDay, theMonth, theYear : STRING;
	i, n, dateDay, dateMonth, dateYear : INTEGER;
BEGIN
	i := POS(dateSeparator, theDate)-1;
	theDay := COPY(theDate, 1, i);
	n := STR2NUM(theDay);
	IF (n<10) THEN theDay := CONCAT('0', theDay);
	DELETE(theDate, 1, i+1);
	i := POS(dateSeparator, theDate)-1;
	theMonth := COPY(theDate, 1, i);
	n := STR2NUM(theMonth);
	IF (n<10) THEN theMonth := CONCAT('0', theMonth);
	DELETE(theDate, 1, i+1);
	theYear := theDate;
	ISOdate := CONCAT('20', theYear, '-', theMonth, '-', theDay);
END;