This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Help: Converting Unix time to readable time
Started by CraftedCart, 03 October 2015 - 06:23 PMPosted 03 October 2015 - 08:23 PM
So I need a small function to convert seconds since epoch to a human readable time. os.date isn't available and I haven't been able to find other stuff. If someone could point me towards something or even write up a function to do so, that would be appreciated.
Posted 03 October 2015 - 08:28 PM
(((UNIX/60)/60)/24)+DATE(1970,1,1 ) is Microsoft Excel version.
(((UNIX/60)/60)/24) returns number of days (including partial days) since 1-1-1970,1,1
DATE(1970,1,1) is just 1-1-1970
(((UNIX/60)/60)/24) returns number of days (including partial days) since 1-1-1970,1,1
DATE(1970,1,1) is just 1-1-1970
Edited on 03 October 2015 - 09:25 PM
Posted 04 October 2015 - 09:23 PM
Posted 04 October 2015 - 09:49 PM
That video is regarding handling times. It even says that Unix time is the best solution. How is this related to the question at hand? OP is asking how to convert Unix time to dd/mm/yy hh:mm:ss format, not how to store dates.
Posted 04 October 2015 - 10:00 PM
You apparently missed… well, most of the video, really. To convert a unix timestamp to a date/time format, you need to know the time zone, and the video described how time zones are trickier than they may appear at first glance.
Also, this is a family-friendly forum, and you can convey your point without cussing.
Also, this is a family-friendly forum, and you can convey your point without cussing.
Posted 05 October 2015 - 07:03 PM
For now, I'm just using an online API, however would prefer if it could be done locally, rather than over the web
Also not bothering with time zones (yet?), just using UTC
Also not bothering with time zones (yet?), just using UTC
Edited on 05 October 2015 - 05:04 PM
Posted 05 October 2015 - 11:08 PM
You're probably going to want to do it online, unless you want to deal with leap seconds, timezones, daylight savings times, the switching of calendars and how different countries switched at different times. You can probably just leave that out and disallow dates under a certain year, but you'll still have to deal with leap seconds and daylight savings.For now, I'm just using an online API, however would prefer if it could be done locally, rather than over the web
Also not bothering with time zones (yet?), just using UTC
Posted 05 October 2015 - 11:19 PM
Use UTC; Ignore leap seconds and time zones. bam problem solved.
Posted 05 October 2015 - 11:58 PM
sure, because being several minutes off from real world time is juuust fine. Leap seconds add up.Use UTC; Ignore leap seconds and time zones. bam problem solved.
Posted 06 October 2015 - 01:54 AM
Over the course of hundreds of years and you still won't see a difference of a minute.
Do you think people skip a second every other week?
Do you think people skip a second every other week?
Edited on 05 October 2015 - 11:54 PM
Posted 06 October 2015 - 02:01 AM
Since 1972 (first leap second) to 2015 there were 26 leap seconds.
Edited on 06 October 2015 - 12:02 AM
Posted 06 October 2015 - 02:07 AM
That's less than a minute in 43 years. It's less than half a minute, in fact.
Posted 06 October 2015 - 07:53 AM
You can probably just leave that out and disallow dates under a certain yearFor now, I'm just using an online API, however would prefer if it could be done locally, rather than over the web
Also not bothering with time zones (yet?), just using UTC
I'm only dealing with dates in the near future (max about 1hr in the future, min: a few seconds)
(Gotta agree with DemHydraz here)
Edited on 06 October 2015 - 05:59 AM