Extral Date and time

Home    Binary distributions    Source distribution    Documentation

The time_scan transforms a string containing date and/or time into a a list of two integers (number of days since 0, and number of miliseconds in that day). These values can be sorted (-dictionary), compared or stored, and transformed back into a human readable date and time string using the time_format command. The clock scan and format commands in Tcl give up before somewhere before 1901 and after 2037, which is a bit of a bummer (eg. for genealogy). The transformation takes into account leap-years properly. However, it extrapolated the current rule to the past (so eg. 0004 BC is a leap year), and doesn't take into account the meddling that has happened to time over time (missing days, ...) because this is nearly impossible to do correctly (I am not an historian). The format of the internal time has been changed since a previous version to using a list of two integers instead of one double value because the accuracy was not good enough to store miliseconds

time_scan time ?date/time/both?
!! the year should be specified fully (>=4 numbers)
	% time_scan {9 May 1997 12:30}
	729152 45000000
time_format time ?formatstring?
!! not all options of clock scan are supported
	%% : %
	%Y : year
	%d : day (09)
	%e : day (9)
	%j : day of year
	%m : month number
	%b : abbreviated month name
	%B : full month name
	%H : hour
	%M : minute
	%S : second
	%s : miliseconds

	% time_format {729152 45000000}
	1997-05-09 12:30:00
	% time_format {729152 45000000} "%B %e %Y"
	May 9 1997

Peter De Rijk
hosted at Get extral at SourceForge.net. Fast, secure and Free Open Source software downloads