Need assistance in converting an epoch time to Julian date
To get epoch
perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"'
Need assistance in converting an epoch time to Julian date
To get epoch
perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"'
Are the numbers in the timelocal function call from a Gregorian date?
Does that mean to want to take a Gregorian date to an Epoch, and now you want to convert it a Julian date?
(it seems like an unusual request, so I just wanted to make sure :))
Yes from Gregarian calender to Julian date
---------- Post updated at 04:39 PM ---------- Previous update was at 01:52 PM ----------
Found a way to get the julian date
use POSIX qw(strftime);
my $time = timegm($sec,$min,$hour,$day,$mon,$year);
print strftime "%j", gmtime($time);
You may try
#!/bin/bash
# Usage : Julian STANDARD DAY MON YEAR HOUR MIN SEC
function Julian(){
std=$1
Day=$2 ; Mon=$3 ; Year=$4
Hour=$5; Min=$6 ; Sec=$7
case "$std" in
CNES )
# Cnes Julian days start at January 1st, 1950
start="Jan 1 1950 12:00:00 AM";;
NASA )
# Nasa Julian days are number of days since January 1st, 1958
start="Jan 1 1958 12:00:00 AM";;
*)
echo "Invalid option" && exit;;
esac
# Julian Day
jd=$(( ( $(date -d "$Year$Mon$Day" +%s) - $(date -d "$start" +%s) ) /(24 * 60 * 60 ) ))
ttime=$(echo $Hour $Min $Sec | awk '{print $2/24 +$3/(60*24)+ $4/(60*60*24)}')
# Realtime Julian Day
rjul=$(echo $jd $ttime | awk '{printf "%5.3f\n", $1+$2}')
}
printf "\nCalendar Date : 31-12-2013 10:10:10\n\n"
# CNES Standard
Julian CNES 31 12 2013 10 10 10
printf "CNES Standard\n\tJulian Day : $jd\n\tRealtime Julian Day : $rjul\n"
# NASA Standard
Julian NASA 31 12 2013 10 10 10
printf "NASA Standard\n\tJulian Day : $jd\n\tRealtime Julian Day : $rjul\n\n"
Resulting
$ ./Julian
Calendar Date : 31-12-2013 10:10:10
CNES Standard
Julian Day : 23375
Realtime Julian Day : 23375.424
NASA Standard
Julian Day : 20453
Realtime Julian Day : 20453.424
following link may be useful to you
http://www.aviso.oceanobs.com/en/data/tools/calendar-days-or-julian-days.html