Ask Your Question
0

error with the date of 16052014

asked 2015-05-10 03:32:59 -0500

updated 2015-05-11 09:17:56 -0500

cobra gravatar image

Dear all, I use Fedora19, and when I use the bash command of date to calculate the next dates after 16052014, I get the following error, but the dates after or before this date don't cause this error, and also with Fedora16, there is no this error:

[envclim]$ sdate=140516
[envclim]$ edate=`date +%y%m%d --date="+2 days ${sdate}"`
date: invalid date ‘+2 days 140516’
[envclim]$ 
[envclim]$ 
[envclim]$ sdate=140515
[envclim]$ edate=`date +%y%m%d --date="+2 days ${sdate}"`
[envclim]$ echo $sdate  $edate 
140515 140517
[envclim]$ 
[envclim]$ 
[envclim]$ sdate=140517
[envclim]$ edate=`date +%y%m%d --date="+2 days ${sdate}"`
[envclim]$ echo $sdate  $edate 
140517 140519

Please, can anyone have any idea about the solution?

Thank you in advance. Zeinab

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-05-12 07:58:52 -0500

Ahmad Samir gravatar image

updated 2015-05-12 08:00:06 -0500

First of all this is a very interesting issue...

This problem is happening due to daylight saving time; on 140515 at midnight the clock jumped one hour forward so the time on 140516 from 00:00:00 to 00:59:59 doesn't exist because 140516, due to DST, starts at 01:00:00; hence the "invalid date" error.

$ zdump -v Africa/Cairo | grep 2014
Africa/Cairo  Thu May 15 21:59:59 2014 UT = Thu May 15 23:59:59 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu May 15 22:00:00 2014 UT = Fri May 16 01:00:00 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Jun 26 20:59:59 2014 UT = Thu Jun 26 23:59:59 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Jun 26 21:00:00 2014 UT = Thu Jun 26 23:00:00 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Jul 31 21:59:59 2014 UT = Thu Jul 31 23:59:59 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Jul 31 22:00:00 2014 UT = Fri Aug  1 01:00:00 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Sep 25 20:59:59 2014 UT = Thu Sep 25 23:59:59 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Sep 25 21:00:00 2014 UT = Thu Sep 25 23:00:00 2014 EET isdst=0 gmtoff=7200

A workaround is to specify some other time as a datum point e.g. noon to get away from time the clock jumps forward:

$ sdate=140516
$ edate=`date +%y%m%d --date="+2 days 12:00 ${sdate}"`
$ echo $edate
140518

I found the solution here:

http://stackoverflow.com/questions/26...

http://www.gnu.org/software/coreutils...

edit flag offensive delete link more

Comments

Thank you so much this error repeated also with date 20150724 but with your command this problem is solved

Zeinab gravatar imageZeinab ( 2015-07-27 06:54:05 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-05-10 03:32:59 -0500

Seen: 51 times

Last updated: May 12 '15