strtotm

Bradley White bww+ at transarc.com
Wed Sep 16 15:19:15 UTC 1992


>> * Prior Art
>> 
>> 	  func		    who			where
>> 	-----------------------------------------------------
>> 	dparsetime()	RAND/UCI		MH
>> 	getabsdate()	Moraes			C News
>> 	getdate()	USL			Sys V Rel 4
>> 	getdate()	Bellovin/Salz/Berets	B News
>> 	parsedate()	Hamey/Accetta		Mach
>> 	partime()	Harrenstien/Eggert	RCS
>> 	strptime()	Harris			SunOS 4.1[.x]

> Are there any routines available that take a "format" parameter so that they  
> can scan dates that are in ambiguous formats.

strptime() [at least] falls into this category -- I believed Guy intended
it as the inverse of strptime() [or at least as close as you can get].

So, ...

	char *
	strptime(buf, fmt, tm)
		char *buf;
		char *fmt;
		struct tm *tm;

	strptime() converts the character string pointed to by buf
	to a time value, which is stored in the tm structure pointed
	to by tm, using the format specified by fmt.

It is available under SunOS.

> I would like to be able to scan dates in any of the following formats:
> 
> M-D-Y T		D-M-Y T

There is no getting around that those D/M-numeric forms are just plain
ambiguous.  The best you can do is to use some ``internationalization''
feature like setlocale(LC_TIME, ...), or to just prefer one over the
other.

> I would like to be able to scan dates in any of the following formats:
> 
> M-D-Y T		D-M-Y T		Y-M-D T
> M/D/Y T		D/M/Y T		Y/M/D T
> M D Y T		D M Y T		Y M D T
> M.D.Y T		D.M.Y T		Y.M.D T

Opinion:  Any generalized date parser is overkill for these restricted
situations.

Brad



More information about the tz mailing list