View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000047 | 1003.1(2008)/Issue 7 | Shell and Utilities | public | 2009-06-25 12:05 | 2011-06-30 17:37 |
| Reporter | eblake | Assigned To | ajosey | ||
| Priority | normal | Severity | Objection | Type | Enhancement Request |
| Status | Closed | Resolution | Duplicate | ||
| 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. | ||||
|
|
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" |
|
|
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. |
|
|
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) |
|
|
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. |
|
|
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. |
|
|
The suggested fix was originally accepted, but has been replaced by changes made in response to bug 0000466. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2009-06-25 12:05 |
|
New Issue | |
| 2009-06-25 12:05 |
|
Status | New => Under Review |
| 2009-06-25 12:05 |
|
Assigned To | => ajosey |
| 2009-06-25 12:05 |
|
Name | => Eric Blake |
| 2009-06-25 12:05 |
|
Organization | => BYU |
| 2009-06-25 12:05 |
|
Section | => date |
| 2009-06-25 12:05 |
|
Page Number | => 2575 |
| 2009-06-25 12:05 |
|
Line Number | => 82893 |
| 2009-06-25 12:13 |
|
Note Added: 0000084 | |
| 2009-06-25 12:13 |
|
Status | Under Review => Resolved |
| 2009-06-25 12:13 |
|
Resolution | Open => Accepted |
| 2009-06-25 12:14 |
|
Note Added: 0000085 | |
| 2009-06-25 12:19 |
|
Note Edited: 0000084 | |
| 2009-06-25 16:38 |
|
Tag Attached: real bug in aardvark | |
| 2009-06-26 06:34 |
|
Note Edited: 0000084 | |
| 2009-06-26 08:11 |
|
Final Accepted Text | => Desired Action |
| 2009-06-26 08:11 |
|
Reporter | Don Cragun => eblake |
| 2009-06-26 12:04 | wpollock | Note Added: 0000114 | |
| 2009-06-26 12:27 |
|
Note Added: 0000117 | |
| 2009-07-30 16:05 | msbrown | Tag Detached: real bug in aardvark | |
| 2009-08-06 00:40 | wpollock | Note Added: 0000172 | |
| 2010-09-09 15:35 |
|
Interp Status | => --- |
| 2010-09-09 15:35 |
|
Resolution | Accepted => Future Enhancement |
| 2010-09-09 15:35 |
|
Tag Attached: issue8 | |
| 2011-06-24 21:00 | eblake | Relationship added | related to 0000169 |
| 2011-06-24 21:13 | eblake | Relationship added | related to 0000466 |
| 2011-06-30 16:26 |
|
Final Accepted Text | Desired Action => |
| 2011-06-30 16:26 |
|
Note Added: 0000872 | |
| 2011-06-30 16:26 |
|
Status | Resolved => Closed |
| 2011-06-30 16:26 |
|
Resolution | Future Enhancement => Duplicate |
| 2011-06-30 16:27 |
|
Tag Detached: issue8 | |
| 2011-06-30 17:37 |
|
Relationship replaced | duplicate of 0000466 |