Bug in Gnu date?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bug in Gnu date?
# 1  
Old 10-30-2018
Bug in Gnu date?

So as I write this today is two days after the clocks go back here in the UK. I have a script that worked last week. Yesterday it developed a bug. I eventually found the culprit is Gnu Date.
Code:
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.5 LTS
Release:	16.04
Codename:	xenial
$ date --version
date (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
$ date --date="15:00"
Mon 29 Oct 15:00:00 GMT 2018
$ date --date="15:00 + 1 minute"
Mon 29 Oct 14:01:00 GMT 2018
$ date --date="15:00 GMT  + 1 minute"
Mon 29 Oct 15:01:00 GMT 2018

So given a time, Gnu date converts it in the local timezone. But apparently if you force date arithmetic on it Gnu date shifts into summertime. I haven't done a thorough investigation into how far this goes. A quick google search didn't find anything.

Has anyone else noticed this phenomenon? Can anyone else reproduce it? Is this a known bug, or should I notify the Gnu Date maintainers?

Andrew
This User Gave Thanks to apmcd47 For This Post:
# 2  
Old 10-30-2018
I cannot reproduce on 8.4, on RHEL/Centos 6.7 or later.
Code:
$ date --date="15:00"
Tue Oct 30 15:00:00 CET 2018
$ date --date="15:00 + 1 minute"
Tue Oct 30 15:01:00 CET 2018

What does hwclock as root output, is it expected ?

Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
# 3  
Old 10-30-2018
Quote:
Originally Posted by Peasant
I cannot reproduce on 8.4, on RHEL/Centos 6.7 or later.
Code:
$ date --date="15:00"
Tue Oct 30 15:00:00 CET 2018
$ date --date="15:00 + 1 minute"
Tue Oct 30 15:01:00 CET 2018

What does hwclock as root output, is it expected ?

Regards
Peasant.
Code:
$ sudo hwclock
Tue 30 Oct 2018 12:49:20 GMT  .265103 seconds
$ date
Tue 30 Oct 12:49:23 GMT 2018

Andrew
# 4  
Old 10-30-2018
Can you show output of :
Code:
ls -lrt /etc/localtime
zdump -v /etc/localtime  | grep "2018" | grep "Oct"

I suspect it's normal behavior on gnu date due to daylight savings, and day having 25 hours.
This is what i've been reading on coreutils list.

Is this behavior still present or just happened on specified date ?

Regards
Peasant.
# 5  
Old 10-31-2018
Nope, still going it today, Weds Oct 31st. Maybe it's a Halloween thing Smilie I'll try it again tomorrow.

Funnily enough I tested this on a Solaris 11 system I have access to, which has Gnu Date installed as /usr/bin/gdate, and it has the same problem. This version of gdate is 8.16.

Andrew
# 6  
Old 10-31-2018
If i put GMT as well in date command, i get same result on every operating system which has gnu date, regardless of the version.

Sorry for the confusion.

Is there a reason you are using GMT in your command or ?

Regards
Peasant.
# 7  
Old 10-31-2018
Quote:
Originally Posted by Peasant
If i put GMT as well in date command, i get same result on every operating system which has gnu date, regardless of the version.

Sorry for the confusion.

Is there a reason you are using GMT in your command or ?

Regards
Peasant.
I haven't explicitly set anything to GMT. My locale is en_GB.utf8 hence:
Code:
$ date
Wed 31 Oct 11:49:43 GMT 2018
$ date --date='last week'
Wed 24 Oct 12:49:57 BST 2018

And, of course,
Code:
$ date +%Z
GMT

What I noticed was that the time, for some reason, was being manipulated as though it was in the timezone UTC+1 and then presented in GMT. If I then forced the time being manipulated to be in GMT I got the result I was expecting.

Thanks for your time in looking at this.

Andrew
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

2. UNIX for Advanced & Expert Users

Regarding question for GNU date

Hello All, Greetings all !! I have a query here, following are the points on same(Adding today's is 31st August 2016 for future reference). 1st Scenario: So while doing some work on GNU date, I wanted to check what was the month(in numbers) by GNU date so I have done following. date... (2 Replies)
Discussion started by: RavinderSingh13
2 Replies

3. Linux

Bug in date command?

Why is the result of this command off (or less) by one hour date --date "1979-10-26 +54 hours" +%Y%m%d%H The result is 1979102805 It actually should be 1979102806 It does it with adding minutes as well and only occurs on Oct. 26, from what I can tell. What's going on here? (9 Replies)
Discussion started by: hsemune
9 Replies

4. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

5. UNIX for Dummies Questions & Answers

Getting date -1 day not using GNU date

It's easy as pie to get the date minus one day on opensolaris: date -d "-1 day" +"%Y%m%d"run this command on our crappy Solaris 10 machines however (which I'm guessing doesn't have GNU date running on it) and you get: date: illegal option -- d date: illegal option -- 1 date: illegal option --... (5 Replies)
Discussion started by: rich@ardz
5 Replies

6. Linux

Date from GNU to BSD

Dear all, This should be simple but I cannot figure it out despite reading all the man pages. Could someone please help me translate this code (GNU date) to one that can be read by BSD date?: myDate=$(date -d "$h -$l days" +%Y/%m/%d), where h is a variable of the form DD/MM/YYYY, and l is... (3 Replies)
Discussion started by: thomchad
3 Replies

7. Shell Programming and Scripting

Howto: easy date range iteration/counting on GNU systems in the shell

Should work in any shell, but requires GNU date, although GNU date seems only to be happy for input dates between 1902 and 2037, inclusive (49673 days). Assume $a and $b hold two dates, e.g. set a=2010-03-27 set b=2010-04-04 Marginally faster: iterator: seq -f "$a +%1.0f days" 1 50000 |... (0 Replies)
Discussion started by: laddiebuck
0 Replies

8. UNIX for Dummies Questions & Answers

GNU Date

I know there are some posts on getting the time with milliseconds included and I realize unix may not be the best on this. I have seem some posts where its advised to install the GNU date. Any one know where I can download this as I am struggling to find it. Alternatively - if you have... (5 Replies)
Discussion started by: frustrated1
5 Replies
Login or Register to Ask a Question