Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jakob Bohm Newsgroups: sci.crypt Subject: Re: [OT] Unix Time Stamp - Independence Day 2025 :-) Date: Fri, 12 Jul 2024 23:45:04 +0200 Organization: WiseMo A/S Lines: 57 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 12 Jul 2024 23:45:07 +0200 (CEST) Injection-Info: dont-email.me; posting-host="9b773ae0db923697192a9e1857a3e506"; logging-data="3377291"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PVsrTMvkRkJ6Y2r3CjZQTVVpS4WORb7M=" Cancel-Lock: sha1:MIQS9pklKvrgK5GsQJObGLHxyIk= X-Mailer: Epyrus/2.1.2 Content-Language: en-US In-Reply-To: Bytes: 3394 On 2024-06-16 22:13, Cri-Cri wrote: > On Sun, 16 Jun 2024 09:43:19 +0200, Stefan Claas wrote: > >> I wonder what else can be done with the Linux 'date' >> command. :-) > > Well, I suppose only one's imagination puts any barriers on that. I'm sure > there are ways to, if not by date alone, so by combining date with other > commands to get what you want. > > Any ideas how to solve calculating the difference between two dates and > report back years, months and days, like an age of some thing, or a > person? > > Like I bought my car on 2015-07-23, how old is it today? And how old will > it be on 2026-07-23? > > That type of thing. > > Example: > https://www.timeanddate.com/date/timeduration.html > > I have a Python gadget that follows how that site does it, by excluding > the end date: > > $ sky -d2age "1970-01-01--2024-06-16" > 54 years, 5 months and 15 days. > > $ sky -d2age "1976-02-29--2024-06-16" > 48 years, 3 months and 18 days. > (In reality, since start year is a leap year, age is 12.0 years.) > > I should really clean that result up a bit. :) > # Beware that this shows one month too many, 1 month old is shown # as 02 (February) etc. Also it doesn't count the specific month # boundaries crossed, just how far into a typical year the excess # days will go. # The values below count age of the example car on the day this is # run under a modern shell like GNU bash, converting to pure # Bourne shell will need variables and extra programs like expr # and printf # The date program is assumed to be the one from the GNU project. date -u '+%y years %m months %d days %H:%M:%S' \ -d @$(( ( ( $(date '+%s') - $(date -d "2015-07-23" '+%s') ) \ / 86400 ) * 86400 + $(date -d '1999-12-31' '+%s') )) Enjoy Jakob -- Jakob Bohm, CIO, Partner, WiseMo A/S. https://www.wisemo.com Transformervej 29, 2860 Søborg, Denmark. Direct +45 31 13 16 10 This public discussion message is non-binding and may contain errors. WiseMo - Remote Service Management for PCs, Phones and Embedded