Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Time::Set(int64 scalar) unexpected results
Re: Time::Set(int64 scalar) unexpected results [message #40732 is a reply to message #40730] Tue, 10 September 2013 20:52 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Alboni,

That is not a bug, it is just how the Time in U++ is designed. Unix timestamp is 32bit number, describing times from 1.1.1970 to someday in 2038. U++ Time works for dates from 4000 B.C. to 4000 A.D. if I remember correctly.

Maybe there is an explicit method to convert the timestamp to Time that I don't know about... But AFAIK the simplest way (at least on POSIX) is to use FileTime, which is just a wrapper around time_t.

So you should be able to do
Time t = FileTime(timestamp);


Another possible solution, that should IMHO work correctly even on windows, could be something like
const Time epoch(1970,1,1);
Time t;
t.Set(epoch.Get()+timestamp);


Best regards,
Honza

PS: You're right about U++ intentionally using year 0 as a center point for time. As it uses signed type, it allows for both negative and positive values so it can accurately represent about 8000 years timespan.

[Updated on: Tue, 10 September 2013 20:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Core/SSL change to let MinGW
Next Topic: Binary file to JSON
Goto Forum:
  


Current Time: Sun Apr 27 21:10:04 CEST 2025

Total time taken to generate the page: 0.00588 seconds