www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Verifying a possible std.date.parse() bug, before I report it

reply David L. Davis <SpottedTiger yahoo.com> writes:
Passing a "MM/DD/YYYY" or "YYYY/MM/DD" formated string into std.date.parse()
function which has a year equal-to or less-than 1970, causes the other std.date
functions to use 1970 internal as the year... messing up the end results.
Needless to say this is throwing my wip dateutils.d module functions off! :( 

Everything above 1970 seems to work just fine, is it me or is this a bug I
should report? Thxs as always, in advance. :))


























<output>
parse( sDate ) is creating a wrong d_time
parse( "07/04/1776" )=0x112A880  )
YearFromTime( parse( "07/04/1776" )=1970

TimeFromYear( 1776 )=0xFFFFFA6E99B1C400 is fine with an integer
YearFromTime( TimeFromYear( 1776 ) )=1776
</output>

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Jul 24 2004
parent J C Calvarese <jcc7 cox.net> writes:
David L. Davis wrote:
 Passing a "MM/DD/YYYY" or "YYYY/MM/DD" formated string into std.date.parse()
 function which has a year equal-to or less-than 1970, causes the other std.date
 functions to use 1970 internal as the year... messing up the end results.
 Needless to say this is throwing my wip dateutils.d module functions off! :( 
 
 Everything above 1970 seems to work just fine, is it me or is this a bug I
 should report? Thxs as always, in advance. :))
Yeah, I'd call it a bug. From http://www.digitalmars.com/d/phobos.html: "typedef d_time: Is a signed arithmetic type giving the time elapsed since January 1, 1970. Negative values are for dates preceding 1970. The time unit used is Ticks. Ticks are milliseconds or smaller intervals." Without studying the code in std\dateparse.d, I'd guess that the negative case of a d_time isn't handled correctly.
 
























 
 <output>
 parse( sDate ) is creating a wrong d_time
 parse( "07/04/1776" )=0x112A880  )
 YearFromTime( parse( "07/04/1776" )=1970
 
 TimeFromYear( 1776 )=0xFFFFFA6E99B1C400 is fine with an integer
 YearFromTime( TimeFromYear( 1776 ) )=1776
 </output>
 
 -------------------------------------------------------------------
 "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Jul 24 2004