RE: ISO8601 date formats

Michael Peppler <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase
Message-ID <[email protected]>
On Tue, 2004-09-21 at 15:14, Avis, Ed wrote:
> How would the date conversion code in DBD::Sybase be called?

At the moment DBD::Sybase has a $dbh->func() call that you can use to
control the date/time formating.

The default format is "SHORT", which corresponds to CS_DATES_SHORT for
the cs_dt_info() call. This generates the Sep 21 2004  3:18PM format in
the US locale. You can use the "LONG" option (which adds seconds and
milliseconds), and various other formats (2004/09/21, etc).

All of this is handled internally by CT-library when you bind a
date/time value as a char string.

I propose to make this just a bit more sophisticated, by binding
date/time values as a CS_DATETIME value (a struct with two 4 byte ints,
the first for the number of days since jan 1 1900, and the second for
the number of milliseconds since midnight).

If the user wants the normal date conversion to happen I simply call
cs_convert() - which is what happens internally when binding as a string
anyway.
If the user wants ISO8601 formats I call cs_dt_crack() to get something
that resembles as struct tm, and then use sprintf or strftime() to build
the char string.

Calling a third-party perl module for each row fetched is NOT an option
due to speed issues.

For example, Sybase::CTlib has the option of creating a
Sybase::CTlib::DateTime perl object for each date/time item that is
fetched. Now I may not have coded this really well (after all I wrote
most of that almost 10 years ago!), but the speed penalty is huge,
making it unusable for all but the smallest data fetches.

In addition the ISO8601 format is one that we all can (or should be able
to) agree on...

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
[email protected]                       http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions - http://www.peppler.org/resume.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.