troubleshooting Question

Urgent: Time and Date calculations.

Avatar of Jammer1224
Jammer1224 asked on
Math / ScienceEditors IDEsProgramming Theory
6 Comments1 Solution1271 ViewsLast Modified:

Since I am creating (atleast trying) a trail version of my software, I am concerned about the time and date parameters.
The user can simply turn his bios or windows clock back and still use the software if using time() or any other functions which are provided by Borland.

To avoid this I decided to get the current time from the time servers.
My current result is the current time (year,month,day,hour,minute,second) stored in different integers.

The main problem of mine is the calculation if the year has changed. For example if the program was started using at 21 of December, 2008 and the current date is 2 January 2009 and the trail period is 30 days the program should still stay active. Also there is alot of problems with february which has a different day count every 4 years and so on. Also every second month has different ammount of days in  it,also daylight saving and other factors.

Well the daylight saving is the last thing to worry about. I'll give away that one free hour :).

I could use time(0) difftime() functions to calculate the correct difference (I hope that they will be correct), but first I have to understand how to convert the current date and the trail start date to the format which uses 1970 01 01 00:00 as the start of calculation. Then understand how to turn the difference of time since that date to seconds. Calculating it would also be a problem because of the February.

Since the program will only be a three day trail the miscalulations of february could turn up a disaster which could end up a 20 or more day trail instead of 3.

Also readed about the Julian Time format, but I'm not sure if it suits my needs.

I saw an object called DateTime in .NET which would solve all my problems. Maby there is something similar in C++/Borland C++?
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros