From: Jelle de Jong <jelledejong@powercraft.nl>
To: 63784@debbugs.gnu.org
Subject: bug#63784: date --date "1 month ago" +%Y-%m does not work as expected on day 31
Date: Mon, 29 May 2023 13:55:04 +0200 [thread overview]
Message-ID: <d7795b0b-3ee2-d937-d337-59bb90f5e715@powercraft.nl> (raw)
Hello everybody,
I been hitting an issue for a while now that date commands return the
wrong month on day 31 of a month and my automations stops working on
correctly on these days.
root@sydney:~# date
Wed Aug 31 22:09:04 CEST 2022
root@sydney:~# date --date "1 month ago" +%Y-%m
2022-07
root@sydney:~# date --date "2 month ago" +%Y-%m
2022-07
root@sydney:~# date --date "3 month ago" +%Y-%m
2022-05
root@sydney:~# date --date "4 month ago" +%Y-%m
2022-05
root@sydney:~# date
Sat Dec 31 19:20:13 CET 2022
root@sydney:~# date --date '1 month ago' +%Y-%m
2022-12
$ date --version
date (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
I would love to have this fixed if possible.
If I am using the wrong command I would love to be educated as well.
Should I use date --date "$(date +%Y-%m-01) -1 month" +%Y-%m instead...
Kind regards,
Jelle de Jong
next reply other threads:[~2023-05-29 13:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 11:55 Jelle de Jong [this message]
2023-05-29 14:27 ` bug#63784: date --date "1 month ago" +%Y-%m does not work as expected on day 31 Pádraig Brady
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://lists.gnu.org/mailman/listinfo/bug-coreutils
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d7795b0b-3ee2-d937-d337-59bb90f5e715@powercraft.nl \
--to=jelledejong@powercraft.nl \
--cc=63784@debbugs.gnu.org \
/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).