Sponsored Content
Full Discussion: Bug in Gnu date?
Top Forums Shell Programming and Scripting Bug in Gnu date? Post 303025537 by apmcd47 on Monday 5th of November 2018 09:13:55 AM
Old 11-05-2018
I've found this message in the bug-coreutils list. It turns out that date is parsing the + 1 as offset from UTC. This can be seen if I use different numbers in my date invocation:
Code:
$ date --date="15:00   + 3 minutes"
Mon  5 Nov 12:01:00 GMT 2018
$ date --date="15:00 + 2 minutes"
Mon  5 Nov 13:01:00 GMT 2018
$ date --date="15:00 + 1 minute"
Mon  5 Nov 14:01:00 GMT 2018
$ date --date="15:00 - 1 minute"
Mon  5 Nov 16:01:00 GMT 2018
$ date --date="15:00 - 2 minutes"
Mon  5 Nov 17:01:00 GMT 2018
$ date --date="15:00 - 3 minutes"
Mon  5 Nov 18:01:00 GMT 2018

Notice how the minute field stays at 01 rather than being incremented (decremented) by the value I specified.
Now, counter-intuitively, I can place the + 1 minute anywhere in the date definition, so
Code:
$ date --date="+ 1 minute 15:00"
Mon  5 Nov 15:01:00 GMT 2018
$ date --date="+ 5 minutes 15:00"
Mon  5 Nov 15:05:00 GMT 2018
$

works as I wanted it to.

So, it is a (known) bug; it is not the bug I thought it was.

Time to mark as solved.

Andrew
These 2 Users Gave Thanks to apmcd47 For This Post:
 

8 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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
install::TempContent::Objects::mod_perl-2.0.9::docs::apiUserRContributed Perinstall::TempContent::Objects::mod_perl-2.0.9::docs::api::APR::Date(3)

NAME
APR::Date - Perl API for APR date manipulating functions Synopsis use APR::Date (); # parse HTTP-complient date string $date_string = 'Sun, 06 Nov 1994 08:49:37 GMT'; $date_parsed = APR::Date::parse_http($date_string); # parse RFC822-complient date string $date_string = 'Sun, 6 Nov 94 8:49:37 GMT'; $date_parsed = APR::Date::parse_rfc($date_string); Description "APR::Socket" provides the Perl interface to APR date manipulating functions. API
"APR::Date" provides the following functions and/or methods: "parse_http" Parse HTTP date strings $date_parsed = parse_http($date_string); arg1: $date_string ( string ) The date string can be in one of the following formats: Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format refer to RFC2616 for the details (GMT is assumed, regardless of the used timezone). ret: $date_parsed ( number ) the number of microseconds since 1 Jan 1970 GMT, or 0 if out of range or if the date is invalid. since: 2.0.00 Remember to divide the return value by 1_000_000 if you need it in seconds. "parse_rfc" Parse a string resembling an RFC 822 date. It's meant to be lenient in its parsing of dates. Hence, this will parse a wider range of dates than "parse_http()". $date_parsed = parse_rfc($date_string); arg1: $date_string ( string ) The date string can be in one of the following formats: Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format Sun, 6 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sun, 06 Nov 94 08:49:37 GMT ; RFC 822 Sun, 6 Nov 94 08:49:37 GMT ; RFC 822 Sun, 06 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] Sun, 6 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] Sun, 06 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] Sun, 6 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] ret: $date_parsed ( number ) the number of microseconds since 1 Jan 1970 GMT, or 0 if out of range or if the date is invalid. since: 2.0.00 Remember to divide the return value by 1_000_000 if you need it in seconds. See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.18.2 2015-06-install::TempContent::Objects::mod_perl-2.0.9::docs::api::APR::Date(3)
All times are GMT -4. The time now is 10:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy