c++ - incorrect value in coledatetime -


i'm fighting few days coledatetime in mfc. have ctime correct values. correct years, days, months, hours, minutes , seconds. tried few ways convert ctime coledatetime:

-1.i put ctime data constructor of coledatetime

coledatetime(int nyear,int nmonth,int nday, int nhour, int nmin,int nsec ); 

-2. formatted ctime time.format("%m/%d/%y %h:%m:%s");

and passed parsedatetime of coledatetime.

-3. tried use setdatetime of coledatetime

after i'm getting incorrect values of minutes 1-2 min. more or less. have never seen before , couldn't find nothing in internet.everybody says abot loss precision second, not minute. please advice me! thank you

i think problem coledatetime internally uses float storage, , value represents number of days since 30 december 1899.

as number of days gets larger, precision of smaller fields (like minutes) decreases. example, float can accurately store values 1000000 , 0.0000001, can't store 1000000.0000001. doesn't have enough bits of precision.

this limitation hinted @ in msdn documentation:

this type used represent date-only or time-only values. convention, date 0 (30 december 1899) used time-only values. similarly, time 0:00 (midnight) used date-only values.

so basically, if want precise time, set date 30 december 1899.

it seems microsoft have designed class store "days" portion integer, hey, easy.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -