Closed warren-gallagher closed 3 weeks ago
Note the double asterisk characters surrounding the error string. Those were added by me in a lame attempt to use the markdown bolding functionality, which of course, does not work within backtick rendering...
@warren-gallagher thanks for your report.
This appears to be a Darwin specific bug, related to date
.
Can you post the man
page for your version of date
?
If you are familiar with date
then you can also try to find the correct syntax for the command in question:
test_date='2026-10-27 17:07:37Z'
date -j -f '%b %d %T %Y %Z' "$test_date" +%s
This should return: 1721926313
, without error.
Man paged attached. If you cat this file it should be the formatted text. date.man.txt
@warren-gallagher I look forward to your PR.. :beer:
test_date='2026-10-27 17:07:37Z' date -j -f '%b %d %T %Y %Z' "$test_date" +%s
This should return:
1721926313
, without error.
Is the example correct?
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
$ echo $TZ
$ timedatectl | grep "Time zone"
Time zone: Europe/Berlin (CEST, +0200)
$ date -d "2026-10-27 17:07:37Z" +%s
1793120857
$ sudo timedatectl set-timezone Etc/UTC
$ timedatectl | grep "Time zone"
Time zone: Etc/UTC (UTC, +0000)
$ date -d "2026-10-27 17:07:37Z" +%s
1793120857
Also, does OpenSSL not return dates (-startdate
, -enddate
, etc.) in RFC 2822 instead of ISO 8601:2004 format?
Oct 27 17:07:37 2026 GMT
vs. 2026-10-27 17:07:37Z
$ node -e "console.log(Date.parse('2026-10-27 17:07:37Z'))"
1793120857000
$ node -e "console.log(Date.parse('Oct 27 17:07:37 2026 GMT'))"
1793120857000
This is how you would parse them on macOS:
$ test_date='2026-10-27 17:07:37Z'
$ date -u -j -f '%Y-%m-%d %H:%M:%SZ' "$test_date" +%s
1793120857
$ test_date='Oct 27 17:07:37 2026 GMT'
$ LC_ALL='C' date -j -f '%b %d %T %Y %Z' "$test_date" +%s
1793120857
Note the usage of -u
:
$ test_date='2026-10-27 17:07:37Z'
$ date -u -j -f '%Y-%m-%d %H:%M:%SZ' "$test_date" +%s
1793120857
$ date -j -f '%Y-%m-%d %H:%M:%SZ' "$test_date" +%s
1793117257
And LC_ALL='C'
:
$ test_date='Oct 27 17:07:37 2026 GMT'
$ LC_ALL='C' date -u -j -f '%b %d %T %Y %Z' "$test_date" +%s
1793120857
$ LC_ALL='en_US.UTF-8' date -u -j -f '%b %d %T %Y %Z' "$test_date" +%s
1793120857
$ LC_ALL='de_DE.UTF-8' date -u -j -f '%b %d %T %Y %Z' "$test_date" +%s
Failed conversion of ``Oct 27 17:07:37 2026 GMT'' using format ``%b %d %T %Y %Z''
date: illegal time format
usage: date [-jnRu] [-r seconds|file] [-v[+|-]val[ymwdHMS]]
[-I[date | hours | minutes | seconds]]
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
$ LC_ALL='de_DE.UTF-8' date -u -j -f '%b %d %T %Y %Z' "Oct 27 17:07:37 2026 GMT" +%s
Failed conversion of ``Oct 27 17:07:37 2026 GMT'' using format ``%b %d %T %Y %Z''
date: illegal time format
usage: date [-jnRu] [-r seconds|file] [-v[+|-]val[ymwdHMS]]
[-I[date | hours | minutes | seconds]]
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
$ LC_ALL='de_DE.UTF-8' date -u -j -f '%b %d %T %Y %Z' "Okt 27 17:07:37 2026 GMT" +%s
1793120857
$ LC_ALL='C' date -u -j -f '%Y-%m-%d %H:%M:%SZ' "2026-10-27 17:07:37Z" +%b
Oct
$ LC_ALL='de_DE.UTF-8' date -u -j -f '%Y-%m-%d %H:%M:%SZ' "2026-10-27 17:07:37Z" +%b
Okt
%b locale's abbreviated month name (e.g., Jan)
https://www.man7.org/linux/man-pages/man1/date.1.html
On Linux, one could use LC_TIME
instead of LC_ALL
but unfortunately macOS' date
does not support it:
macOS
$ LC_ALL='de_DE.UTF-8' date -u -j -f '%Y-%m-%d %H:%M:%SZ' "2026-10-27 17:07:37Z" +%b
Okt
$ LC_TIME='de_DE.UTF-8' date -u -j -f '%Y-%m-%d %H:%M:%SZ' "2026-10-27 17:07:37Z" +%b
Oct
Linux
$ LC_TIME='de_DE.UTF-8' date -d "2026-10-27 17:07:37Z" +%b
Okt
@sdavids Thanks for your work, I'll take a closer look soon.
@warren-gallagher Please test the PR #1211
@sdavids If you have access to a macOS system then please test #1211
$ git clone git@github.com:TinCanTech/easy-rsa.git
$ cd easy-rsa
$ git checkout tools-macos-certdate-to-timestamp
Switched to a new branch 'tools-macos-certdate-to-timestamp'
$ die() { print "$1${NL}" }
$ verbose() { printf '%s\n' " # $*" }
$ force_set_var() { eval "export \"$1\"=\"\${$1-$2}\"" }
$ export EASYRSA_TOOLS_CALLER=1
$ export LC_ALL='de_DE.UTF-8'
$ . dev/easyrsa-tools.lib
$ echo $EASYRSA_TOOLS_VERSION
321
$ cert_date_to_timestamp_s "2026-10-27 17:07:37Z" ISO_8601
$ echo $ISO_8601
1793120857
$ cert_date_to_timestamp_s "Oct 27 17:07:37 2026 GMT" RFC_2822
# DEPRECATED: cert_date_to_timestamp_s
cert_date_to_timestamp_s:
'date' failed for in_date=Oct 27 17:07:37 2026 GMT
$ echo $RFC_2822
You forgot the LC_ALL='C'
.
When running the show-expire command I encountered the following error:
When I show-cert for the 'offending' certificate it shows the following: