Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

julian date help

Status
Not open for further replies.

encourage

Programmer
Apr 16, 2002
5
IN
how do i convert gregorian date to equivalent julian date in
C shell
 
encourage:

I've never seen a good solution to this question in unix shell. Over the years, I've collected several utilities in "C" (written by guys smarter than me) that answer this question, and other date related questions.

Provide an email address, and I'll send you the "C" source.

Regards,


Ed
Schaefer
 
olded,

thanks a lot for ur response .

my email address is sunbaj@mailcity.com

hope to recieve a repply from u as early as possible

regards
sunil
 

This works in ksh assuming a command line parameter of a valid date in the format YYYYMMDD.

#!/bin/ksh

yr=$(echo $1 | cut -c1-4)
mth=$(echo $1 | cut -c5-6)
day=$(echo $1 | cut -c7-8)

while [ $mth -gt 1 ]; do
mth=$(($mth - 1))
set $(cal $mth $yr)
shift $(($# - 1))
day=$((day + $1))
done

echo $(printf "%4d%.3d" $yr $day)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top