Convert string time into seconds?

Guy Harris guy at auspex.auspex.com
Sat Jul 15 05:17:21 AEST 1989


>Is there an ANSI C/Posix/WhateverStandardYouCareToNominate function that will
>convert from a time in a string (as produced by asctime()/ctime()) ?

No, but you could snatch the "getdate" function from, among other
places, the netnews source (as Steve Bellovin, author of that function,
may already have noted); it uses a YACC parser to accept quite a number
of time formats, and if it doesn't handle "asctime()" format you can
probably whack it to do so.

It currently does the equivalent of what "mktime()" does itself, but you
could rewhack it to use "mktime()", at the expense of possibly
eliminating its ability to parse dates with explicit time zone
specifications in them. 



More information about the Comp.unix.wizards mailing list