Julian date display?

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
gittist
Level 1
Level 1
Posts: 45
Joined: Tue Oct 31, 2017 6:30 pm

Julian date display?

Post by gittist »

Hi,

I use Julian dates just about every day. Instead of looking up the Julian date on a chart it would be nice if it displayed on the lower right hand corner (or anywhere, even the desktop) what the day's current Julian date is.

Does anyone know of an application or program that will do that?

I am running Kernel: 5.8.0-55-generic x86_64 bits: 64 compiler: N/A Desktop: Cinnamon 4.8.6 wm: muffin dm: LightDM Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal

Thanks
User avatar
xenopeek
Level 25
Level 25
Posts: 25626
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Julian date display?

Post by xenopeek »

There are plenty of libraries for programmers to convert dates to other systems but I didn't spot any applet, extension or other program that can do what you want for Cinnamon.

You could make something yourself. The python3-convertdate package looks promising. After installing that package (through Synaptic or with apt install python3-convertdate command) you can for example make this Python script and when run from the terminal it will (I think -- no clue what I'm doing wrt Julian calendar :lol:) print the current Julian date in two formats:

Code: Select all

#!/usr/bin/python3
from datetime import date
from convertdate import julian, gregorian

print(julian.from_gregorian(date.today().year, date.today().month, date.today().day))

print(gregorian.to_jd(date.today().year, date.today().month, date.today().day))
You put that in a text file. After saving the file right-click it and go to Properties > Permissions and tick the box to allow executing as program. Then open the terminal on the directory where you have the script and run it as ./filename or python3 filename. Right now for me that prints:

Code: Select all

(2021, 5, 29)
2459376.5
Is either correct or what you want?

The converdate library has good documentation for more options: https://convertdate.readthedocs.io/en/latest/

If you can find something that does what you want we can next figure out how to show it somewhere on your desktop or something.

But hopefully I overlooked something obvious and somebody is aware of a program you can use for this :wink:
Image
User avatar
Larry78723
Level 12
Level 12
Posts: 4465
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: Julian date display?

Post by Larry78723 »

The following bash script outputs today's Julian date (without year) in a terminal.

Code: Select all

#!/bin/bash

date +%j
I don't know how you'd display that on the panel.
Image
User avatar
xenopeek
Level 25
Level 25
Posts: 25626
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Julian date display?

Post by xenopeek »

Larry78723 wrote:
Fri Jun 11, 2021 1:11 pm
The following bash script outputs today's Julian date (without year) in a terminal.
Does it? That doesn't sound quite right. The manpage says +j% prints "day of year (001..366)". How is that a Julian date?
Image
DAMIEN1307
Level 12
Level 12
Posts: 4143
Joined: Tue Feb 21, 2017 8:13 pm
Location: Alamogordo, New Mexico, USA

Re: Julian date display?

Post by DAMIEN1307 »

ORDO AB CHAO
"I refuse to be assimilated, I refuse to become one with the Borg Collective"
User avatar
Larry78723
Level 12
Level 12
Posts: 4465
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: Julian date display?

Post by Larry78723 »

I assumed (I know, I know) that the OP was talking about Julian date as used in the U.S. government, i.e. 2021163 (year + day number) based on his statement
I use Julian dates just about every day. Instead of looking up the Julian date on a chart it would be nice if it displayed on the lower right hand corner (or anywhere, even the desktop) what the day's current Julian date is.
I don't believe he was talking about the Julian calendar.
Image
rene
Level 17
Level 17
Posts: 7773
Joined: Sun Mar 27, 2016 6:58 pm

Re: Julian date display?

Post by rene »

Larry78723 wrote:
Fri Jun 11, 2021 1:53 pm
I don't believe he was talking about the Julian calendar.
If he is: going by the definition of JD as provided by https://en.wikipedia.org/wiki/Julian_day (and the 2000-01-01 anchor it provides) it can be displayed as

Code: Select all

echo "scale=5; 2451545 + ($(date +%s) - $(date -d "2000-01-01 12:00 UTC" +%s))/(24 * 60 * 60)" | bc
User avatar
Larry78723
Level 12
Level 12
Posts: 4465
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: Julian date display?

Post by Larry78723 »

Based again on the OP's statement, I believe that the correct term for what they need is now called "Ordinal date".
Ordinal date is the preferred name for what was formerly called the "Julian date" or JD, or JDATE, which still seen in old programming languages and spreadsheet software. The older names are deprecated because they are easily confused with the earlier dating system called Julian day number or JDN, which was in prior use and which remains ubiquitous in astronomical and some historical calculations.
We really need clarification as to their need.
Image
rene
Level 17
Level 17
Posts: 7773
Joined: Sun Mar 27, 2016 6:58 pm

Re: Julian date display?

Post by rene »

Larry78723 wrote:
Fri Jun 11, 2021 2:23 pm
Based again on the OP's statement, I believe that the correct term for what they need is now called "Ordinal date".
Very likely, and in that case with preferred formatting taken from https://en.wikipedia.org/wiki/Ordinal_date, slightly tweaking your answer:

Code: Select all

date +%Y-%j
In Xfce you can set a custom clock format by rclicking the systray clock and in properties set the format e.g. %H:%M (%Y-%j). Dunno right now for other DEs.
User avatar
Larry78723
Level 12
Level 12
Posts: 4465
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: Julian date display?

Post by Larry78723 »

@rene - That works in Cinnamon too.
Image
rene
Level 17
Level 17
Posts: 7773
Joined: Sun Mar 27, 2016 6:58 pm

Re: Julian date display?

Post by rene »

Great. If OP was in fact talking about the https://en.wikipedia.org/wiki/Julian_day JD one then he'd need a (simple) custom applet but if OD indeed it's then been answered I guess.
gittist
Level 1
Level 1
Posts: 45
Joined: Tue Oct 31, 2017 6:30 pm

Re: Julian date display?

Post by gittist »

@rene - Thank you! It's not exactly the format I was looking for but it tells me what I needed to know :D
Post Reply