Debian Bug report logs - #664959
gawk: mktime fails when date changes to daylight savings time

version graph

Package: gawk; Maintainer for gawk is Adrian Bunk <bunk@debian.org>; Source for gawk is src:gawk (PTS, buildd, popcon).

Reported by: Sebastian Luque <spluque@gmail.com>

Date: Wed, 21 Mar 2012 20:51:24 UTC

Severity: normal

Found in version gawk/1:3.1.8+dfsg-0.1

Done: Jeroen Schot <schot@A-Eskwadraat.nl>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Information forwarded to debian-bugs-dist@lists.debian.org, Arthur Loiret <aloiret@debian.org>:
Bug#664959; Package gawk. (Wed, 21 Mar 2012 20:51:27 GMT) (full text, mbox, link).


Acknowledgement sent to Sebastian Luque <spluque@gmail.com>:
Extra info received and forwarded to list. Copy sent to Arthur Loiret <aloiret@debian.org>. (Wed, 21 Mar 2012 20:51:27 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Sebastian Luque <spluque@gmail.com>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: gawk: mktime fails when date changes to daylight savings time
Date: Wed, 21 Mar 2012 15:47:31 -0500
Package: gawk
Version: 1:3.1.8+dfsg-0.1
Severity: normal

Dear Maintainer,

With the following program (test.awk):

---<--------------------cut here---------------start------------------->---
{print fix_time($0)}
function fix_time(tstr) {     # tstr=time string field
    if (length(tstr) != 21 || !tstr) {
	return tstr
    } else {
	Y=substr(tstr, 2, 4)
	M=substr(tstr, 7, 2)
	D=substr(tstr, 10, 2)
	h=substr(tstr, 13, 2)
	m=substr(tstr, 16, 2)
	s=substr(tstr, 19, 2)
	t=mktime(sprintf("%s %s %s %s %s %s", Y, M, D, h, m, s))
	return strftime("%Y-%m-%d %H:%M:%S", t)
    }
}
---<--------------------cut here---------------end--------------------->---

$ echo '"2012-03-11 01:00:00"' | gawk -f test.awk
2012-03-11 01:00:00
$ echo '"2012-03-11 02:00:00"' | gawk -f test.awk
2012-03-11 03:00:00
$ echo '"2012-03-11 03:00:00"' | gawk -f test.awk
2012-03-11 03:00:00
$ echo '"2012-03-11 04:00:00"' | gawk -f test.awk
2012-03-11 04:00:00

$ echo '"2012-03-12 01:00:00"' | gawk -f test.awk
2012-03-12 01:00:00
$ echo '"2012-03-12 02:00:00"' | gawk -f test.awk
2012-03-12 02:00:00
$ echo '"2012-03-12 03:00:00"' | gawk -f test.awk
2012-03-12 03:00:00

Daylight savings for my local time zone (Central Time) started on
2012-03-11.  Time is not interpreted correctly for the second hour of
the day when daylight savings starts.


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing-proposed-updates'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages gawk depends on:
ii  libc6        2.13-27
ii  libsigsegv2  2.9-4

gawk recommends no packages.

gawk suggests no packages.

-- no debconf information


-- 
Seb




Information forwarded to debian-bugs-dist@lists.debian.org, Arthur Loiret <aloiret@debian.org>:
Bug#664959; Package gawk. (Wed, 21 Mar 2012 22:21:32 GMT) (full text, mbox, link).


Message #8 received at 664959@bugs.debian.org (full text, mbox, reply):

From: Bob Proulx <bob@proulx.com>
To: Sebastian Luque <spluque@gmail.com>, 664959@bugs.debian.org
Subject: Re: Bug#664959: gawk: mktime fails when date changes to daylight savings time
Date: Wed, 21 Mar 2012 15:40:21 -0600
Sebastian Luque wrote:
> $ echo '"2012-03-11 02:00:00"' | gawk -f test.awk
> 2012-03-11 03:00:00
> ...
> Daylight savings for my local time zone (Central Time) started on
> 2012-03-11.  Time is not interpreted correctly for the second hour of
> the day when daylight savings starts.

Please state your canonical timezone?  Central Time by itself is
ambiguous.  But I can guess.

Note that 2012-03-11 02:00:00 is an invalid date in Central time.
There is no correct interpretation possible.  Or perhaps the only
correct interpretation would be to throw an exception error.

  $ TZ=US/Central date -R -d '2012-03-11 02:00:00'
  date: invalid date `2012-03-11 02:00:00'

What should awk do with invalid dates?  Should it report them as
invalid as gnu date does?  Probably.

See this useful reference for coreutils date.  (Of course I am biased
about its usefulness. :-)

  http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e

Bob




Information forwarded to debian-bugs-dist@lists.debian.org, Arthur Loiret <aloiret@debian.org>:
Bug#664959; Package gawk. (Thu, 22 Mar 2012 03:15:03 GMT) (full text, mbox, link).


Acknowledgement sent to Sebastian P. Luque <spluque@gmail.com>:
Extra info received and forwarded to list. Copy sent to Arthur Loiret <aloiret@debian.org>. (Thu, 22 Mar 2012 03:15:03 GMT) (full text, mbox, link).


Message #13 received at 664959@bugs.debian.org (full text, mbox, reply):

From: Sebastian P. Luque <spluque@gmail.com>
To: Bob Proulx <bob@proulx.com>
Cc: 664959@bugs.debian.org
Subject: Re: Bug#664959: gawk: mktime fails when date changes to daylight savings time
Date: Wed, 21 Mar 2012 22:12:34 -0500
On Wed, 21 Mar 2012 15:40:21 -0600,
Bob Proulx <bob@proulx.com> wrote:

> Sebastian Luque wrote:
>> $ echo '"2012-03-11 02:00:00"' | gawk -f test.awk 2012-03-11 03:00:00
>> ...  Daylight savings for my local time zone (Central Time) started
>> on 2012-03-11.  Time is not interpreted correctly for the second hour
>> of the day when daylight savings starts.

> Please state your canonical timezone?  Central Time by itself is
> ambiguous.  But I can guess.

> Note that 2012-03-11 02:00:00 is an invalid date in Central time.
> There is no correct interpretation possible.  Or perhaps the only
> correct interpretation would be to throw an exception error.

>   $ TZ=US/Central date -R -d '2012-03-11 02:00:00' date: invalid date
> `2012-03-11 02:00:00'

> What should awk do with invalid dates?  Should it report them as
> invalid as gnu date does?  Probably.

> See this useful reference for coreutils date.  (Of course I am biased
> about its usefulness. :-)

>   http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e

Yes, I totally agree.  We were discussing this in the awk newsgroup
(http://groups.google.com/group/comp.lang.awk/browse_thread/thread/1e77bcbb851fd4ea#).


-- 
Seb




Reply sent to Jeroen Schot <schot@A-Eskwadraat.nl>:
You have taken responsibility. (Thu, 05 Apr 2012 14:03:10 GMT) (full text, mbox, link).


Notification sent to Sebastian Luque <spluque@gmail.com>:
Bug acknowledged by developer. (Thu, 05 Apr 2012 14:03:11 GMT) (full text, mbox, link).


Message #18 received at 664959-done@bugs.debian.org (full text, mbox, reply):

From: Jeroen Schot <schot@A-Eskwadraat.nl>
To: 664959-done@bugs.debian.org
Subject: Re: gawk: mktime fails when date changes to daylight savings time
Date: Thu, 5 Apr 2012 15:59:21 +0200
Version: 1:3.1.8+dfsg-0.1


Hello,

Thanks for your bug report. While the current behavior is surprising,
there is nothing gawk can do about it. The mktime functions is simply
a wrapper around the C/POSIX function with the same name and by design
has the same semantics. This function even explicitly allows out of
range values, as documented in the gawk man page. In comp.lang.awk I
see Geoff Clare reaching the same conclusion. 

Regards,

Jeroen Schot




No longer marked as fixed in versions 1:3.1.8+dfsg-0.1. Request was from Andreas Beckmann <anbe@debian.org> to control@bugs.debian.org. (Sat, 02 Nov 2013 15:58:26 GMT) (full text, mbox, link).


Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Sun, 01 Dec 2013 07:38:29 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Oct 11 23:39:31 2017; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.