www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - std.date.parse() bug when year <= 1970

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, I sure hope this can be fixed by the next
version. 

Walter, Thxs for all the hard work you're putting into this Baby! :)) <Soapbox>
I'm still waiting on the ifind and ireplace functions. As you may have
noticed...I don't debate (besides others are better at it), so I spent most of
my time writing D code for myself and to share with others. So I do hope you can
give the D runtime library some good old TLC soon. You know, it's really all
your fault, for creating such a wonderful "Language" that I'm hooked into
writing code in it! Keep up the good work!! :)</Soapbox>

# import std.stdio;
# import std.date;
#
# int main()   
# {
#    char[] sDate = "07/04/1776";
#    int    iYear = 1776;
#    
#    writefln( "parse( sDate ) is creating a wrong d_time");
#    writefln( "parse( \"%s\" )=0x%-X  )", sDate, parse( sDate )  );
#    
#    writefln( "YearFromTime( parse( \"%s\" )=%-d", 
#               sDate, YearFromTime( parse( sDate ) ));
#               
#    writefln( "\n" ); 
#    
#    writefln( "TimeFromYear( %d )=0x%-X is fine with an integer",
#               iYear, TimeFromYear( iYear ) );         
#    writefln( "YearFromTime( TimeFromYear( %d ) )=%-d", 
#               iYear, YearFromTime( TimeFromYear( iYear ) ) );         
#
#    return 0;
#    
# } // end int main()

<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