create file with Julian date and current time --- then subtract 5 minutes
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
create file with Julian date and current time --- then subtract 5 minutes
I need to create a one record file that contains information that looks similar to the one below. The record will always contain the number 70 in columns 1 and 2. The other entries are the date and time both to and from in the format of yyddd(ddd is Julian) and time in hhmm.
Once this file is created I will need to continue to create new files that have the time increase by 5 minutes. If the date changes that will need to change as well. The format of the file needs to look like this:
position 1 and 2 -- 70, positions 11-15 current date in yyddd format, positions 16-19 current time in format hhmm, positions 20-24 to date in yyddd format and positions 25-28 increment of 5 minutes in hhmm format. Here is an example of the entry:
As somebody who uses julian date (and modified julian date) every day, it really bothers me when somebody calls ordinal date/day of year "julian"...
[/soapbox]
If this is bash, you can use date to spit out that date string, and you can use the "-d" flag to tell it what time to use, including "+5 minutes" to get the time 5 minutes in the future.
Last edited by suicidaleggroll; 06-12-2014 at 11:38 AM.
Someone should talk to the maintainers of the 'date' program then, since the number of days since the beginning of the year is %j instead of %o. That is probably contributing to the misnomer.
edit: I sent an email to the coreutils maintainers at gnu.org pointing it out. Perhaps something will be done about it. Probably not though, since it will break scripts left and right. But perhaps a note in the manual page would be nice.
The OP is looking for an example or some code,.. using the 'date' program, and the horribly named %j parameter, we could do something like:
Code:
TMP=`date +%y%j%H%m%y%j%H%m`
while true; do
echo 70 70 $TMP
let TMP=TMP+5
done
Last edited by szboardstretcher; 06-12-2014 at 11:57 AM.
There are two different definitions for Julian date. POSIX has
standardized %j to mean the count of days within a Gregorian year, and
NOT the astronomical Julian date. http://pubs.opengroup.org/onlinepubs/9699919799/toc.htm
We are reluctant to burn %o without it being required by POSIX, because
strftime letters are already sparse; this is particularly true of
burning a letter to be a synonym to an already standardized letter. The
proposal in the thread mentioned above would be to add a %J as the
Astronomical Julian date, if there proves to be enough demand, but so
far, no one has expressed enough interest to actually write the patch.
Therefore, I'm closing this as not a bug, although you can feel free to
add further replies to the thread.
Of course, the argument against it is tight as well. The wikipedia article suicidaleggroll references straight up says that outside of Astronomy/historical context, ie computers, that Julian date means exactly what was proposed at the beginning of this thread.
Quote:
Outside of an astronomical or historical context, if a given "Julian date" is "40", this most likely means the fortieth day of a given Gregorian year, namely February 9.
Last edited by szboardstretcher; 06-12-2014 at 02:41 PM.
The wikipedia article suicidaleggroll references straight up says that outside of Astronomy/historical context, ie computers, that Julian date means exactly what was proposed at the beginning of this thread.
Just because some people use it in that fashion doesn't mean it's correct
A lot of people use the phrase "I could care less" when they are trying to say they don't care about something. It doesn't mean that's the correct saying.
Last edited by suicidaleggroll; 06-12-2014 at 03:08 PM.
I wonder that the US Military's definition of "Julian Date" is. They use it, or I've seen it in some accompanying documentation on the contracts I saw at General-Atomics for the Predator Aircraft.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.