~mil/sxmo-tickets#446: 
replace date -d with portable alternative

problem: date -d is not POSIX, thus does not work on every posix-compliant system see https://www.unix.com/man-page/posix/1P/date/

3 ideas come to mind option 1: replace every occurence with a C wrapper around the posix strftime? https://www.unix.com/man-page/posix/3p/strftime/

option 2: "" with a shell script that does the math for us [slow]

option 3: use awk '{ print strftime("%F%T%z", $0) }' NOT posix, but widespread, even in openbsd awk - the easiest and smallest solution

I've seen date -d being used i.e. for sms logs - getting the timestamp from the file i.e. "2022-01-1121:03:14+01:00" and reformatting it.

Status
REPORTED
Submitter
~noneofyourbusiness
Assigned to
No-one
Submitted
10 months ago
Updated
4 months ago
Labels
good-first-issue

~noneofyourbusiness 10 months ago

~phartman REPORTED FIXED 7 months ago

~noneofyourbusiness 7 months ago

~phartman FIXED REPORTED 7 months ago

~wentam 5 months ago

Not just sxmo_modem.sh - here's a few more instances of date -d:

$ grep -nr 'date.* -d'
scripts/modem/sxmo_vvm.sh:17:	VVM_DATE="$(date +%FT%H:%M:%S%z -d "$1")" # date of voice mail
scripts/modem/sxmo_modem.sh:190:		TIME="$(date +%FT%H:%M:%S%z -d "$TIME")"
scripts/modem/sxmo_mms.sh:184:	DATE="$(date +%FT%H:%M:%S%z -d "$DATE")"
scripts/appscripts/sxmo_rss.sh:29:	TIME=$(eval date -d \""$TIMESPAN"\" +%s)
scripts/appscripts/sxmo_weather.sh:81:			tput setaf 14; date -d "@$NOWDAY" +'%a %b %d'; tput sgr0
configs/default_hooks/sxmo_hook_statusbar.sh:33:	CALLSTARTS="$(date +"%s" -d "$(

~noneofyourbusiness 4 months ago

Since alpine is already making their own POSIX utils with some GNU extensions, it's fine with me. sbase also implements -d. I guess you can keep this one around as wontfix (after documenting why exactly in the docs)

Register here or Log in to comment, or comment via email.