views:

89

answers:

6

The number 71867806 represents the present day, with the smallest unit of days. Sorry guy's, caching owned me, it's actually milliseconds!

How can I

  • calculate the currente date from it?
  • (or) convert it into an Unix timestamp?

Solution shouldn't use language depending features.

Thanks!

+3  A: 

This depends on:

  • What unit this number represents (days, seconds, milliseconds, ticks?)
  • When the starting date was

In general I would discourage you from trying to reinvent the wheel here, since you will have to handle every single exception in regards to dates yourself.

ntziolis
Some other guy invented this, i need to find out what it means. The smallest unit's are days. I can only guess the starting day and it would be very vague if not totally wrong.
elias
I'll give you the accept for being first and giving the general advices that lead me into the right directon. Even thought with a clear mind it wasn't that hard. :)
elias
A: 

It is indeed a fairly long time ago if the smallest number is in days. However, assuming you're sure about it I could suggest the following shell command which would be obviously not valid for dates before 1st Jan. 1970:

date -d "@$(echo '(71867806-71853086)*3600*24'|bc)" +%D

or without bc:

date -d "@$(((71867806 - 71853086) * 3600 * 24))" +%D
Jon
Which gives the wrong result.
elias
Yes, you're right. Initially I assumed the smallest increment was seconds not days. What is interesting to notice is that the current date in seconds minus the figure you gave (interpreted in seconds) gives 1200008140 seconds since 1970 which is the 11. Jan 2008. Maybe this is a special date since when a particular task is running. My (major) edit above reflects your statement that you're sure that the smallest increment is a day.
Jon
+1  A: 

If it's truly an integer number of days, and the number you've given is for today (April 21, 2010, for me as I'm reading this), then the "zero day" (the epoch) was obviously enough 71867806 days ago. I can't quite imagine why somebody would pick that though -- it works out to roughly 196,763 years ago (~194,753 BC, if you prefer). That seems like a strange enough time to pick that I'm going to guess that there's more to this than what you've told us (perhaps more than you know about).

It seems to me the first thing to do is verify that the number does increase by one every 24 hours. If at all possible keep track of the exact time when it does increment.

Jerry Coffin
+1  A: 

First, you have only one point, and that's not quite enough. Get the number for "tomorrow" and see if that's 71867806+1. If it is, then you can safely bet that +1 means +1 day. If it's something like tomorrow-today = 24, then odds are +1 means +1 hour, and the logic to display days only shows you the "day" part. If it's something else check to see if it's near (24*60, which would be minutes), (24*60*60, which would be seconds), or (24*60*60*1000, which would be milliseconds).

Once you have an idea of what kind of units you are using, you can estimate how many years ago the "start" date of 0 was. See if that aligns with any of the common calendar systems located at http://en.wikipedia.org/wiki/List_of_calendars. Odds are that the calendar you are using isn't a truly new creation, but a reimplementation of an existing calendar. If it seems very far back, it might be an Julian Date, which has day 0 equivalent to BCE 4713 January 01 12:00:00.0 UT Monday. Julian Dates and Modified Julian dates are often used in astronomy calculations.

The next major goal is to find Jan 1, 1970 00:00:00. If you can find the number that represents that date, then you simply subtract it from this foreign calendar system and convert the remainder from the discovered units to milliseconds. That will give you UNIX time which you can then use with the standard UNIX utilities to convert to a time in any time zone you like.

In the end, you might not be able to be 100% certain that your conversion is exactly the same as the hand implemented system, but if you can test your assumptions about the calendar by plugging in numbers and seeing if they display as you predicted. Use this technique to create a battery of tests which will help you determine how this system handles leap years, etc. Remember, it might not handle them at all!

Edwin Buck
+1  A: 

What time is: 71,867,806 miliseconds from midnight?

There are:
- 86,400,000 ms/day
- 3,600,000 ms/hour
- 60,000 ms/minute
- 1,000 ms/second

Remove and tally these units until you have the time, as follows:

How many days? None because 71,867,806 is less than 86,400,000

How many hours? Maximum times 3,600,000 can be removed is 19 times 71,867,806 - (3,600,000 * 19) = 3,467,806 ms left.

How many minutes? Maximum times 60,000 can be removed is 57 times. 3,467,806 - (60,000 * 57) = 47,806 ms left

How many seconds? Maximum times 1,000 can be removed is 47 times. 47,806 - (1,000 * 47) = 806

So the time is: 19:57:47.806

NealB
A: 

Sorry again for the messy question, i got the solution now. In js it looks like that:

var dayZero = new Date(new Date().getTime() - 71867806 * 1000);
elias