coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggested feautre: "date --debug" - print date parsing diagnostics


From: Assaf Gordon
Subject: Re: suggested feautre: "date --debug" - print date parsing diagnostics
Date: Fri, 22 Jan 2016 22:03:18 -0500

Attached an improved and cleaned-up patch.

In addition to parsing/error/warnings, it also prints progress messages (in the 
code, these are PROGRESS vs DEBUG macros).

There are few missing things, mainly how to properly display debug timezone 
information (suggestions welcomed).

comments welcomed,
 - assaf


Attachment: coreutils-debug-date.v1.patch
Description: Binary data

Attachment: gnulib-debug-parse-date.v1.patch
Description: Binary data



For example, these are the debug messages for the very recent 'bug' report
( http://lists.gnu.org/archive/html/bug-coreutils/2016-01/msg00030.html ):

The reported 'bug', due to user's timezone:
===
$ ./src/date --debug -d @0 +%X
date: parsed timespec part: timespec=0 seconds
date: final epoch-seconds: 0.000000000
date: final date: '(Y-M-D) 1970-01-01 00:00:00' UTC
19:00:00
===

versus the user's other attempt:
(NOTE that additional hint is needed to explain why midnight in the current 
timezone was converted to 18000 epoch, then to 05:00:00 in my timezone, which 
then, after timezone adjustment, was printed as midnight).
===
$ ./src/date --debug -d '1970/1/1' +%X
date: warning: value 1970 has 4 digits. Assuming YYYY/MM/DD
date: parsed date part: (Y-M-D) 1970-01-01 
date: warning: using midnight as starting time: 00:00:00
date: starting date/time: '(Y-M-D) 1970-01-01 00:00:00'
date: '(Y-M-D) 1970-01-01 00:00:00' = 18000 epoch-seconds
date: final epoch-seconds: 18000.000000000
date: final date: '(Y-M-D) 1970-01-01 05:00:00' UTC
00:00:00
===

The first example from the Coreutils FAQ:
===
$ ./src/date --debug -d  "2006-04-02 02:30:00"
date: parsed date part: (Y-M-D) 2006-04-02 
date: parsed time part: 02:30:00 
date: using specified time as starting value: '02:30:00'
date: error: invalid date/time value:
date:     user provided time: '(Y-M-D) 2006-04-02 02:30:00'
date:        normalized time: '(Y-M-D) 2006-04-02 03:30:00'
date:                                             --      
date:      possible reasons:
date:        non-existing due to daylight-saving time;
date:        numeric values overflow;
date:        missing timezone;
./src/date: invalid date ‘2006-04-02 02:30:00’
===

Using invalid dates:
===
$ ./src/date --debug -d  "2006-02-30"
date: parsed date part: (Y-M-D) 2006-02-30 
date: warning: using midnight as starting time: 00:00:00
date: error: invalid date/time value:
date:     user provided time: '(Y-M-D) 2006-02-30 00:00:00'
date:        normalized time: '(Y-M-D) 2006-03-02 00:00:00'
date:                                       -- --         
date:      possible reasons:
date:        invalid day/month combination;
date:        numeric values overflow;
date:        missing timezone;
./src/date: invalid date ‘2006-02-30’
===

Relative dates:
===
$ ./src/date --debug -d  "now - 3 months + 99 minutes"
date: parsed relative part: today/this/now
date: parsed relative part: -3 month(s) 
date: parsed relative part: -3 month(s) +99 minutes 
date: using current time as starting value: '21:42:38'
date: using current date as starting value: '(Y-M-D) 2016-01-22'
date: starting date/time: '(Y-M-D) 2016-01-22 21:42:38'
date: after date adjustment (+0 years, -3 months, +0 days),
date:     new date/time = '(Y-M-D) 2015-10-22 22:42:38'
date: '(Y-M-D) 2015-10-22 22:42:38' = 1445568158 epoch-seconds
date: after time adjustment (+0 hours, +99 minutes, +0 seconds, +0 ns),
date:     new time = 1445574098 epoch-seconds
date: final epoch-seconds: 1445574098.210781000
date: final date: '(Y-M-D) 2015-10-23 04:21:38' UTC
Fri Oct 23 00:21:38 EDT 2015
===

Warning about ambiguous formats:
===
$ ./src/date --debug -d '11/12/13'
date: warning: value 11 has less than 4 digits. Assuming MM/DD/YY
date: parsed date part: (Y-M-D) 0013-11-12 
date: warning: adjusting year value 13 to 2013
date: warning: using midnight as starting time: 00:00:00
date: starting date/time: '(Y-M-D) 2013-11-12 00:00:00'
date: '(Y-M-D) 2013-11-12 00:00:00' = 1384232400 epoch-seconds
date: final epoch-seconds: 1384232400.000000000
date: final date: '(Y-M-D) 2013-11-12 05:00:00' UTC
Tue Nov 12 00:00:00 EST 2013
===



reply via email to

[Prev in Thread] Current Thread [Next in Thread]