GNU bug report logs - #72023
feature request for date(1): strptime-style format string when you don't want date to guess

Previous Next

Package: coreutils;

Reported by: <mark.yagnatinsky <at> barclays.com>

Date: Wed, 10 Jul 2024 02:20:01 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Stephane Chazelas <stephane <at> chazelas.org>
To: 72023 <at> debbugs.gnu.org
Subject: bug#72023: feature request for date(1): strptime-style format
Date: Tue, 10 Sep 2024 06:57:45 +0100
I agree strptime()-style input format specification is badly
missing in GNU date. Most other implementations support it:

- BSD with -f since 1997 (on FreeBSD at least; see also -v for adjustments)
- ast-open's with -p since 2004 (also via standard getdate() DATEMSK)
- busybox' with -D since 2006
- toybox' with -D since 2014

It's a regular occurrence on usenet or unix.stackexchange.com to
see it mentioned that if you need to parse arbitrary date
formats, you need to switch to another date implementation or
use shell builtin facilities such as zsh's strftime builtin or
ksh93's printf %T or resort to perl/ruby/python...

Assaf Gordon did propose a patch in
https://lists.gnu.org/archive/html/coreutils/2019-07/msg00053.html

Both -p and -D are unassigned ATM AFAICT so could be used here.
busybox and toybox mostly copied the GNU API, so it would make
sense for GNU date to use -D for that so they don't become
misaligned.

While strptime() is not perfect, it's still better IMO
than having to rely on the current -d behaviour which mostly
accepts only US-English time specs and whose rules to parse
times are not crystal clear.

-- 
Stephane




This bug report was last modified 278 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.