You are not logged in.
The date command is very useful.
In this case, it is necessary to calculate the difference date2 - date1.
This could be an interesting example:
date1
The 1984 Summer Olympics (Los Angeles) closed August 12, 1984.
https://en.wikipedia.org/wiki/1984_Summer_Olympics
date2
The 2028 Summer Olympics (Los Angeles) opening July 14, 2028.
https://en.wikipedia.org/wiki/2028_Summer_Olympics
Let's calculate how much time will pass between these dates.
Notes *
The date command will use the time in seconds.
A day lasts 86400 seconds (24 hours * 60 minutes * 60 seconds).
Difference in days:
$ echo $((($(date +%s -d 20280714) - $(date +%s -d 19840812)) / 86400))
16042
Or with python3:
$ python3 -c 'from datetime import date; print (date(2028,7,14)-date(1984,8,12))'
16042 days, 0:00:00
There are many great scripts (bash, python) that you can easily find, but they all work on a similar basis.
If people would know how little brain is ruling the world, they would die of fear.
Offline
Been using date in conkys for years.
My mistake: dateutils for years
Last edited by Sector11 (2024-08-16 03:02:32)
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
dateutils can make life simpler:
dateutils.ddiff 1984-09-12 2028-07-14
16011
dateutils.ddiff 1984-09-12 2028-07-14 -f '%Y years %m months %d days'
43 years 10 months 2 days
Offline
dateutils can make life simpler:
dateutils.ddiff 1984-09-12 2028-07-14 16011 dateutils.ddiff 1984-09-12 2028-07-14 -f '%Y years %m months %d days' 43 years 10 months 2 days
Exactly how I use it in conky.
For example Quit Smoking:
S11: 08-06-09:${color0}${pre_exec dateutils.ddiff 2009-06-08 'today' -f ' %y·%m·%d'}${color}
Displays
It's great for Birthdays, Anniversaries, etc. - I'm always forgetting those.
If you look for a future date the result has a " - " in front of it.
NOTE:
Debian requires 'dateutils.diff' other distros may only require 'dateutils'
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Exactly how I use it in conky.
I also use dateutils in conky's. I learned that from you once.
Edit: here in siduction there is no dateutils-diff, only dateutils
Last edited by unklar (2024-08-16 14:33:38)
Offline
Sector11 wrote:Exactly how I use it in conky.
I also use dateutils in conky's. I learned that from you once.
We have learned a lot from each other over the years.
Shared and grown - together.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
here in siduction there is no dateutils-diff, only dateutils
There's no package called dateutils-diff anywhere, it's dateutils you have to install.
'dateutils.ddiff' is one of the commands it provides.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Online
RE: dateutils
A long time ago when I started checking out dateutils I found that the commands did not work in Debian as seen from various sites on the internet,
Then I came across a site that stated in Debian the command must be prefixed with "dateutils." ← note the dot or period
so
ddiff
became
dateutils.ddiff
fresse org - datediff command
- talks about
$ datediff ...
Ubuntu Manpages - ddiff
- talks about
$ ddiff ...
GitHub for dateutils
- talks about
$ datediff ...
Debian manpaged for dateutils
- talks about
$ ddiff ...
in the examples - scroll down
- - but that doesn't work
Now look at the "url" on the top line on that page, see that: dateutils.ddiff
- that works
In my terminal:
2024·08·17 @ 15:31:12 ~
$ dateutils.ddiff 2009-06-08 'today' -f ' %y·%m·%d'
15·2·9
2024·08·17 @ 15:33:07 ~
$ ddiff 2009-06-08 'today' -f ' %y·%m·%d'
bash: ddiff: command not found
2024·08·17 @ 15:33:14 ~
$ datediff 2009-06-08 'today' -f ' %y·%m·%d'
bash: datediff: command not found
2024·08·17 @ 15:33:44 ~
$
As John and I said: same program dateutils
- different ways to use it in different distros.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Good thread, I've just downloaded dateutils now.
Offline
Enjoy.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline