Anonymous | Login | 2024-12-12 15:09 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0000047 | [1003.1(2008)/Issue 7] Shell and Utilities | Objection | Enhancement Request | 2009-06-25 12:05 | 2011-06-30 17:37 | ||
Reporter | eblake | View Status | public | ||||
Assigned To | ajosey | ||||||
Priority | normal | Resolution | Duplicate | ||||
Status | Closed | ||||||
Name | Eric Blake | ||||||
Organization | BYU | ||||||
User Reference | |||||||
Section | date | ||||||
Page Number | 2575 | ||||||
Line Number | 82893 | ||||||
Interp Status | --- | ||||||
Final Accepted Text | |||||||
Summary | 0000047: Missing specifiers for date utility | ||||||
Description |
Although the date utility provides an interface similar to the strftime function, there are several things specified only for the latter (some with CX shading), which would be useful from a command line interface. These include: missing specifiers, addition of flags, addition of minimum field width. This aardvark only addresses missing specifiers. An alternative solution might be to couch the entire discussion of the format argument of the date utility in terms of a call to strftime, so that the next time the strftime interface is extended, the date utility implicitly picks up that extension; this would also pick up the '0' and '+' flags as well as minimum field width. |
||||||
Desired Action |
At line 82893, insert: %F Date in the format %Y-%m-%d %g The last 2 digits of the week-based year (see %V) as a decimal number [00,99]. %G The week-based year (see %V) as a decimal number (for example, 1977). At line 82903, insert: %R Time in the format %H:%M. At line 82922, insert: %z The offset from UTC in the ISO 8601:2000 standard format (+hhmm or -hhmm), or by no characters if no timezone is determinable. For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich). |
||||||
Tags | No tags attached. | ||||||
Attached Files | |||||||
|
Relationships | |||||||||||
|
Notes | |
(0000084) Don Cragun (manager) 2009-06-25 12:13 edited on: 2009-06-26 06:34 |
Originally reported by ebb9:xxxxxxx Fri, 9 Jan 2009 21:00:38 GMT with Subject: Defect in XCU date Transcribed by Don Cragun from xcubug3.txt ERN 3 Submitter tag "ebb.date" |
(0000085) Don Cragun (manager) 2009-06-25 12:14 |
This is an enhancement, and should be added SD5, items for consideration for the next revision. It should be noted that the proposed action does not address all the issues raised in the problem specifications. |
(0000114) wpollock (reporter) 2009-06-26 12:04 |
I thought you had agreed to add "%s" to this aardvark? Please consider re-opening this, and add: %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. (TZ) |
(0000117) Don Cragun (manager) 2009-06-26 12:27 |
The request we were given was to add missing specifiers from strftime() and strptime() to the list of specifiers supported by the date utility. The %s specifier is not in strftime() or strptime() in the standard. |
(0000172) wpollock (reporter) 2009-08-06 00:40 |
Opps, I must have accidentally checked my logal (Gnu) man page for strftime rather than the standard, sorry! However I can't help but feel this is a serious omission. Currently the only way is to use the time function from <time.h>, but that isn't useful for shell scripting! I currently use code like this: TIME=$(awk 'BEGIN { srand(); print srand(); }') which works on all systems I've tried it on. But a careful reading of SUSv4 says this for the AWK srand function: "srand([expr]) Set the seed value for rand to expr or use the time of day if expr is omitted. The previous seed value shall be returned." However this isn't guaranteed to be the "the value of time in seconds since the Epoch", as defined by time(). Therefore the only way is to caclulate this manually using the POSIX formula. A pure shell script had an overflow when I tried, so I ended up with this script using bc: SEC=$(date +%S) MIN=$(date +%M) HOUR=$(date +%H) # 24 hour format YDAY=$(date +%j) # Day of year (num of days since last December 31) YEAR=$(date +%Y) # 4 digit year YEAR=$(( YEAR - 1900 )) SECONDS_SINCE_EPOCH=$( bc <<END scale = 0 $SEC + 60 * $MIN + $YDAY * 86400 + \ ($YEAR-70)*31536000 + (($YEAR-69)/4) * 86400 - \ (($YEAR-1)/100)*86400 + (($YEAR+299)/400)*86400 END ) printf '%s\n' "$SECONDS_SINCE_EPOCH" This is so ugly! Please, pretty please, consider adding '%s' to date? You could add it to strftime as well, for consistency sake! This is often requested functionality for non Gnu users. |
(0000872) Don Cragun (manager) 2011-06-30 16:26 |
The suggested fix was originally accepted, but has been replaced by changes made in response to bug 0000466. |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |