- Code Golf Hole Four - Unix Time
- 06 May 2020 03:22:43 pm
- Last edited by LogicalJoe on 12 May 2020 02:32:41 pm; edited 10 times in total
I know that it's a busy time of year, with the end of the school year and whatnot, but I figured an easy golf could be a welcome break from the chaos that is the outside world.
This program should take the on-calc time and return the Unix/Epoch time in Ans (Assuming the on-calc time is UTC). If you don't know what Unix time is, you can glance over the [Wikipedia page], but in short, Unix Time is the number of seconds since midnight on Jan 1, 1970 (UTC) minus leap seconds.
It only needs to output values from between calculator and unix compatible times, which leads to the range of 00:00:00 Jan 1, 1997 (852076800) [calc min] to 03:14:07 Jan 19, 2038 (2147483647) [Unix max] To find out why this is the Unix max, you can read the [Wikipedia page] on the K2k38 problem.
To test different times, I use epochconverter.com.
Examples:
Code:
Requirements:
Size: The program's size is measured as:
Code:
Lowest score wins! Good luck!
Don't forget about leap years!
Current Results:
Other results:
This program should take the on-calc time and return the Unix/Epoch time in Ans (Assuming the on-calc time is UTC). If you don't know what Unix time is, you can glance over the [Wikipedia page], but in short, Unix Time is the number of seconds since midnight on Jan 1, 1970 (UTC) minus leap seconds.
It only needs to output values from between calculator and unix compatible times, which leads to the range of 00:00:00 Jan 1, 1997 (852076800) [calc min] to 03:14:07 Jan 19, 2038 (2147483647) [Unix max] To find out why this is the Unix max, you can read the [Wikipedia page] on the K2k38 problem.
To test different times, I use epochconverter.com.
Examples:
Code:
getDate
{2020,1,1
getTime
{0,0,0
0:prgmU:Ans
1577836800
getDate
{2017,9,2
getTime
{5,10,24
0:prgmU:Ans
1504329024
Requirements:
- Input: None
- Freshly reset calc (every variable reset to 0/not defined [except the time, obviously])
- Valid on-calc time
- Output: Integer in Ans with the Unix time that corresponds with the on-calc time.
- The only time-based functions allowed are getTime and getDate (no dbd, startTmr, checkTmr, setDate, or setTime), but I would be happy to see other obscure functions.
Size: The program's size is measured as:
Code:
on-calc-size - 9 - length(name)
Don't forget about leap years!
Current Results:
Other results: