I need to convert Julian timestamp to Regular timestamp in UNIX using Bash.
On Tandem OS, conversion is pretty straightforward –
Example:
212186319010244541
$OLSAPP SYSTST 1> #interprettimestamp 212186319010244541
#interprettimestamp 212186319010244541 expanded to:
2455860 2011 10 25 16 10 10 244 541
I wish to do the same on UNIX environment. The conversion will be a part of a parser script. So one-liners would be greatly appreciated.
UPDATE:
INTERPRETTIMESTAMP inbuilt function on Tandem returns a space-separated list of nine numbers, consisting of the Julian day number, year, month, day, hour, minute, second, millisecond, and microsecond.
Assuming the number is as @blahdiblah says
Then you first need to know the Julian timestamp for 01-JAN-1970 which is the epoch for unix time. So a cludgy oracle query gives
Then you could in theory just have a shell command to compute the number of seconds since 1-Jan-1970.
The problems with this are:
Now if you have perl installed you can solve these using the
bigintandPOSIXmodules. As a shell “one” liner it looks likeWhich gives
The 1 hour difference is probably due to daylight savings differences. It could be either in the perl, or more likely the value I used for 01-Jan-1970 could be an hour out. So you may need to check both of them to be sure its right for your system.