Artificial intelligent assistant

Convert a number of seconds elapsed to date from arbitrary start date I want to convert a particular amount of seconds to a date. In my case the it's the number of seconds elapsed since 1st of January 0001. If it were for seconds elapsed from epoch it would be easy: `$ date -r nr_of_seconds`. It would be awesome if there was a way of telling `date` to start at a particular date. Is there such an option (the `-v` option almost does what I need, ... I think)? I'm on a Mac.

`date -r` almost does the job. All you need to do is shift the origin, which is an addition.


date -r $((number_of_seconds - epoch))


where `epoch` is the number of seconds between 1 January 1 and 1 January 1970. The value of `epoch` depends on your calendar.

In the Gregorian calendar, there are 477 leap years between 1 and 1970, so 365 * 1969 + 477 = 719162 days = 62135596800 seconds. Note that this number is greater than 232, so you'll need a shell capable of 64-bit arithmetic to handle it. Your `number_of_seconds` will be more than 232 anyway if it represents dates beyond the second century AD. I think bash supports 64-bit arithmetic even on older, 32-bit OSX but I'm not sure.


date -r $((number_of_seconds - 62135596800))

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 6d9f32df531e04df258f5994be49597c