Re: generic time parsing functions, getdate() DATEMSK examples, and
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Re: generic time parsing functions, getdate() DATEMSK examples, and




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-31-05 10: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.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:52 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register