LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools Search this Thread
Old 09-10-2008, 01:38 AM   #1
nanda22
Member
 
Registered: Mar 2008
Posts: 58
Thanked: 0
date in julian format


[Log in to get rid of this advertisement]
Hi

I want the current date in julian format stored into one variable.
Please help me
nanda22 is offline  
Tag This Post , , ,
Reply With Quote
Old 09-10-2008, 02:02 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 5.4
Posts: 8,107
Thanked: 401
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
chrism01 is offline     Reply With Quote
Old 09-10-2008, 02:27 AM   #3
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732
Thanked: 6
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.
pinniped is offline     Reply With Quote
Old 09-10-2008, 02:56 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 5.4
Posts: 8,107
Thanked: 401
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.
chrism01 is offline     Reply With Quote
Old 09-10-2008, 09:39 AM   #5
AnanthaP
Member
 
Registered: Jul 2004
Location: India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 246
Thanked: 1
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
AnanthaP is offline     Reply With Quote
Old 09-10-2008, 12:36 PM   #6
GazL
Senior Member
 
Registered: May 2008
Location: England.
Posts: 1,004
Thanked: 107
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"

GazL is offline     Reply With Quote
Old 09-10-2008, 01:07 PM   #7
bibh_lnxq
Member
 
Registered: Nov 2004
Location: Leiden, Netherlands
Distribution: SuSE; Fedora;Slackware
Posts: 58
Thanked: 0
[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.
bibh_lnxq is offline     Reply With Quote

Reply


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


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


All times are GMT -5. The time now is 04:16 PM.

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.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration