Unix Programming - Re: generic time parsing functions, getdate() DATEMSK examples, and

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2005 > Re: generic time parsing functions, getdate() DATEMSK examples, and





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: generic time parsing functions, getdate() DATEMSK examples, and
Chuck Dillon

2005-01-31, 5:55 pm

Paul Sheer wrote:
> I would like a function that parses an ascii string
> into a struct tm. The function should support a
> variety of time formats for a variety of locales.
> It should not only parse the time, but determine
> what standard of format has been given.
>
> It seems silly that no such function has yet been
> written. Is it not possible? or is there some
> reason why one would never want to do this?


Probably because people tend to need deterministic solutions for this
kind of data. At the same time a heuristic solution, like you are
looking for, tends not to be applicable to general purpose usage and so
probably wouldn't be offered publicly. For example, you specify an
ASCII string. If I were to write such a magical function I certainly
wouldn't limit it to ASCII input, it would be informed by the locale
and so would likely make decisions that were problemattic for you.

One other point, I would submit that if such a function could
reasonably be developed database vendors would have this capability to
facility handling of date data, which can be painful. All database
systems I've worked with require explicit specification of formats when
converting/storing date data.

-- ced

>
> Currently there are a variety of date formats like
> ISO, W3C, RFC822, asctime() and others. If I don't
> know what kind of time format I am going to get,
> I would like the function to tell me,
> as well as the locale. If there is an
> ambiguity, to indicate a list of probable
> formats ordered by likelihood. The latter is a
> tall order, I know, but a nice-to-have. The
> function should also understand all known time-zone
> abbreviations and return the GMT offset if possible.
> If the time format seems to have missing offset
> information, then this should be indicated as a
> warning.
>
> Alternatively, the getdate() man page mentions
> a DATEMSK envvar that points to a file. Where can
> I get an example of such a file that contains all
> the common time formats in use? This would mostly
> solve my problem.
>
> Note that I have read the man pages: localtime(3),
> strftime(3), strptime(3), time(3), date(1),
> gettimeofday(2), newctime(3), time(2), utime(2),
> clock(3), difftime(3), strftime(3), tzset(3),
> getdate().
>
> (Also, to really be useful, the source for this
> function must be available in both Pascal, Java,
> and ANSI-C. And it must also have a reverse
> function.)
>
> Thanks for any help!
>
> -paul
>
>
>



--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com