LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 09-10-2008, 12:38 AM   #1
nanda22
Member
 
Registered: Mar 2008
Posts: 58

Rep: Reputation: 15
date in julian format


Hi

I want the current date in julian format stored into one variable.
Please help me
 
Old 09-10-2008, 01:02 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.2, Centos 5.8
Posts: 11,696

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
Depends on which one: http://en.wikipedia.org/wiki/Julian_day
but seconds since 1970 (aka Unix epoch) is date %s, see man date.
%j day-of-yr
 
Old 09-10-2008, 01:27 AM   #3
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 49
There is only ONE Julian Day (aka Julian Date). The day-of-year thing is bullshit (although, unfortunately, very commonly accepted bullshit) - that is NOT a Julian date - that is what some ignoramuses (ignorami?) from the management world called the day-of-year (Ordinal Day of Year, as accepted in the ISO terminology), so parroting that is promoting ignorance and confusion as to what a Julian date is.

Anyway, this link may get you started:

http://aa.usno.navy.mil/data/docs/JulianDate.php

The US Naval Observatory also has other useful web pages discussing time, but I can't seem to find them at the moment. Just to confuse things, some of the positive dates in the Julian Date system actually preceed the use of the Julian Calendar, and these are known as the Proleptic Julian Dates. In a similar fashion, dates written as a Gregorian Date but before the establishment of the Gregorian Calendar (such as dates typically quoted in history books) are proleptic Gregorian dates.

So if you really want Julian Dates, you need to read a bit about the history of time and look up conversions. If you can get a copy of a current edition of the Royal Astronomical Almanac, you may find a simple calculation of the Julian Date referenced to a more recent epoch; if you want something more accurate (not made obsolete in the near future or past) you will need to do a lot more reading.
 
Old 09-10-2008, 01:56 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.2, Centos 5.8
Posts: 11,696

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
Easy Tiger, I was just pointing out his options. That also includes the Wiki page which points out various 'definitions' of such 'dates' and the history thereof, inc links to eg USN Observatory.

You don't know which one he actually wants.
 
Old 09-10-2008, 08:39 AM   #5
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 458

Rep: Reputation: 58
You know the old poem:

30 days hath September, April, June and November,
All the other days but February have 31,
February has 28 unless its a leap year.

Build these datas into an array.

Its possible to so given an year, you determine whether its a leap year or not.
Then offset days for the elapsed months, (Jan 0, Feb 31 ..)
Add days in the current month.

There is the same example in K&R (in C).
It can be easily written in any other programming language and also in shell script also.

End
 
Old 09-10-2008, 11:36 AM   #6
GazL
Senior Member
 
Registered: May 2008
Posts: 2,368

Rep: Reputation: 472Reputation: 472Reputation: 472Reputation: 472Reputation: 472
Even big technology players like IBM refer to ordinal dates as 'julian date format'. YY.DDD was a very common format on their MVS mainframes and probably still is. It's a little harsh to call it 'bullshit'. It's actually a very useful date format. Far more useful than the number of days from some ancient epoch for most uses, unless you're doing something with astronomical data when an ancient epoch is probably quite vital.

I think its a pretty safe bet what he's looking for is the more commonly (if incorrectly) used meaning,

date +%Y-%j is most likely the correct answer in this case.


Anyway, could be worse, if it was based on the Chinese year then today would be
"Rat-216"

 
Old 09-10-2008, 12:07 PM   #7
bibh_lnxq
Member
 
Registered: Nov 2004
Location: Leiden, Netherlands
Distribution: SuSE; Fedora;Slackware
Posts: 58

Rep: Reputation: 15
[QUOTE=pinniped;3275435]
Quote:
Originally Posted by pinniped View Post
ignoramuses (ignorami?)
Off topic, I know, but I cannot resist.
ignoramus = "we know not", sometimes "we do not want to know".
There is no Latin plural of ignoramus; it is a (non-nominal) form of a verb and it is not the same -us as in fungus.
Your "ignoramuses" is right.
 
  


Reply

Tags
date, format


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date format ust Linux - Newbie 2 12-21-2007 01:39 PM
Julian date from calender date tostay2003 Programming 16 08-17-2007 11:06 AM
date format kalleanka LQ Suggestions & Feedback 9 11-15-2006 11:36 AM
Regarding date Format ancys Programming 4 08-10-2006 05:35 AM
Date format Mik LQ Suggestions & Feedback 8 12-05-2004 10:14 AM


All times are GMT -5. The time now is 05:02 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration