From: <tomas@tuxteam.de>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guile-user@gnu.org
Subject: Re: timestamp
Date: Sat, 12 Feb 2022 13:32:58 +0100 [thread overview]
Message-ID: <Ygeo+pHmUuLUyTR9@tuxteam.de> (raw)
In-Reply-To: <874k54tia0.fsf@elephly.net>
[-- Attachment #1: Type: text/plain, Size: 2244 bytes --]
On Sat, Feb 12, 2022 at 12:49:10PM +0100, Ricardo Wurmus wrote:
>
> Hi adriano,
>
> I’ve got no good answers as to “why” things are the way they are, but
> the manual explains the range of these values:
>
> > It seesm to be
> >
> > (tm:mon %3)
> >
> > This returns
> >
> > 11
> >
> > I expected 12 but ok, I recognize this kind of weirdness
>
> -- Scheme Procedure: tm:mon tm
> -- Scheme Procedure: set-tm:mon tm val
> Month (0-11).
>
> > I'm unhappy with
> >
> > (tm:year $3)
> >
> > This returns
> >
> > 120
> >
> > it's 2020
> >
> > Why would 120 represent 2020 ?
>
> -- Scheme Procedure: tm:year tm
> -- Scheme Procedure: set-tm:year tm val
> Year (70-), the year minus 1900.
>
> I don’t know why this would be useful, but that’s what it is ¯\_(ツ)_/¯
Oh. That is old POSIXy tradition :-)
Guile actually only passes along what libc provides, and I think it is a
good idea, in general. See the man page of localtime(3) on your next Linux-ish
box for all the details. If you prefer an online version, perhaps [1], [2]
convey an idea.
The year... those interfaces were developed well before the year 2000. It was
usual, Back Then (TM) to write down the year as a two-digit number (the 19
prefix was implied). Nobody could predict that the year 2000 was about to
arrive, honestly ;-)
As to the month... zero based numberings ease computations and setting up
name arrays (as in: 0: January, 1: February and so on).
Don't ask me why, though, the day of the month (1..31) is one-based. It is
the only exception :-)
But it makes for an easy calculation where you can add up the year (times
year length, taking leap years into account), the days-in-month so far for
full months and the current month day and things to arrive at the current
Epoch day. Guess one has to be one-based, otherwise you'll have to add 1 at
the end.
(This is all somewhat tongue-in-cheek ;-P
But it illustrates some other point: for folks coming from C and POSIX, (I
do), all that stuff feels "pretty natural", although it isn't, of course.
Cheers
[1] https://en.cppreference.com/w/c/chrono/localtime
[2] https://en.cppreference.com/w/c/chrono/tm
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2022-02-12 12:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 8:37 timestamp adriano
2022-02-12 8:52 ` timestamp Vivien
2022-02-12 9:43 ` timestamp adriano
2022-02-12 11:49 ` timestamp Ricardo Wurmus
2022-02-12 12:32 ` tomas [this message]
2022-02-12 12:38 ` timestamp Eli Zaretskii
2022-02-12 13:30 ` timestamp adriano
2022-02-12 13:42 ` timestamp adriano
2022-02-12 13:49 ` timestamp Ricardo Wurmus
2022-02-12 13:55 ` timestamp adriano
2022-02-12 14:01 ` Guile cookbook ? adriano
2022-02-12 14:15 ` Ricardo Wurmus
2022-02-12 15:01 ` adriano
2022-02-12 15:30 ` Olivier Dion via General Guile related discussions
2022-02-12 17:11 ` Zelphir Kaltstahl
2022-02-12 17:32 ` timestamp Eli Zaretskii
2022-02-12 17:48 ` Examples in Guile documentation Zelphir Kaltstahl
2022-02-12 9:01 ` timestamp tomas
2022-02-12 9:49 ` timestamp adriano
2022-02-12 12:50 ` timestamp Eli Zaretskii
2022-02-12 13:01 ` timestamp tomas
2022-02-12 15:23 ` timestamp adriano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ygeo+pHmUuLUyTR9@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=guile-user@gnu.org \
--cc=rekado@elephly.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).