bug#37961: Bug report of date commond

2019-10-28 Thread Paul Eggert

On 10/28/19 12:34 AM, zhangzhi...@mail.iap.ac.cn wrote:

~>date  -d "1940-06-01" +"%Y-%m-%d"
date: invalid date ‘1940-06-01’


Presumably your TZ setting is Asia/Shanghai, as I see the symptoms as 
follows:


$ TZ=Asia/Shanghai date  -d "1940-06-01" +"%Y-%m-%d"
date: invalid date ‘1940-06-01’

This is because there is no instant of time 1940-06-01 00:00:00 in 
Shanghai, as the the clock ticked over from 1940-05-30 23:59:59 to 
1940-06-01 01:00:00 due to a daylight-saving time transition.


For this particular case, you'll have better luck with:

$ date -d "1940-06-01 12:00" +"%Y-%m-%d"

but this sort of approach does not work in general, because 12:00 does 
not always exist either. In other words, the 'date' command is not 
suited for calendrical arithmetic in general, only for time arithmetic.






bug#37961: Bug report of date commond

2019-10-28 Thread zhangzhi...@mail.iap.ac.cn
Mr. maintainers:
Hello! I am very glad to write this email to report my problem.
When I am running commond on my server: 

~>date  -d "1940-06-01" +"%Y-%m-%d"
date: invalid date ‘1940-06-01’

but the other commond works right:
sense3:~>date  -d '1939-06-01' +"%Y-%m-%d"
1939-06-01
sense3:~>date  -d '1940-06-02' +"%Y-%m-%d"
1940-06-02
sense3:~>date  -d '1940-05-31' +"%Y-%m-%d"
1940-05-31
sense3:~>date  -d '1940-07-02' +"%Y-%m-%d"
1940-07-02
sense3:~>date  -d '1940-07-01' +"%Y-%m-%d"
1940-07-01
sense3:~>date  -d '1940-05-01' +"%Y-%m-%d"
1940-05-01


my server's version and date version is:
~>uname -a
Linux zenglab 3.10.0-957.12.1.el7.x86_64 #1 SMP Mon Apr 29 14:59:59 UTC 2019 
x86_64 x86_64 x86_64 GNU/Linux
~>date --version
date (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
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.

This error makes my program woking wrong. Hope for your reply.

Thank you!






 张志敏 技术工程师
单位:中国科学院大气物理研究所 大气科学和地球流体力学数值模拟国家重点实验室(LASG)地址:中国北京市朝阳区德胜门外祁家豁子华严里40#,北京,100029 
 邮箱:zhangzhi...@mail.iap.ac.cn
电话:13391835740


bug#6236: Bug report in Date Command

2010-06-07 Thread Bob Proulx
Eric Blake wrote:
 This is a mailing list frequented by lots of readers.  I'm not David,
 but I can reply.

By coincidence I am not David either.  But will respond too anyway. :-)

 lijian 65631 wrote:
  When I input the comman 'date +%Y%m%d -d 1986-05-04 1 day' to get the
  next day of '1986-05-04', I get the result as below.
  
  Maybe it is a bug of Date command , Please help to find it, Thanks.
 
 Thanks for the report.  However, it is most likely the only bug here is
 your understanding of how date operates around daylight savings events:
 http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e

I am confident that this is related to daylight savings time and that
it is answered in the FAQ.  Not having seen any activity on this issue
for a while I am going to close it in the bug tracking system.  Please
feel free to follow up if it has not answered your questions and the
group will see and read your message and the bug tracker will keep
track of it for us.

Bob





bug#6236: Bug report in Date Command

2010-05-21 Thread Eric Blake
On 05/20/2010 08:07 PM, lijian 65631 wrote:
 Dear David,

This is a mailing list frequented by lots of readers.  I'm not David,
but I can reply.

 
 When I input the comman 'date +%Y%m%d -d 1986-05-04 1 day' to get the
 next day of '1986-05-04', I get the result as below.
 
 Maybe it is a bug of Date command , Please help to find it, Thanks.

Thanks for the report.  However, it is most likely the only bug here is
your understanding of how date operates around daylight savings events:
http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e

 This e-mail and its attachments contain confidential information from

It is considered poor netiquette to include employer disclaimers on mail
sent to publicly archived mailing lists, where the disclaimer is
rendered ineffective.  Consider using a personal account instead.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


bug#6236: Bug report in Date Command

2010-05-20 Thread lijian 65631
Dear David,

 

When I input the comman 'date +%Y%m%d -d 1986-05-04 1 day' to get the
next day of '1986-05-04', I get the result as below.

Maybe it is a bug of Date command , Please help to find it, Thanks.



 

Regards,

 

 Lijian 65631
 Email:  mailto:jay...@huawei.com jay...@huawei.com
 Tel  : 13510271503  0755-28979991
 Dept : Consumer Service Development Dept, HS


-
This e-mail and its attachments contain confidential information from
HUAWEI, which 
is intended only for the person or entity whose address is listed above. Any
use of the 
information contained herein in any way (including, but not limited to,
total or partial 
disclosure, reproduction, or dissemination) by persons other than the
intended 
recipient(s) is prohibited. If you receive this e-mail in error, please
notify the sender by 
phone or email immediately and delete it!

 

attachment: image002.jpg

Bug report for date

2009-07-28 Thread Paul Grinberg
Hi,

 

Gives me correct date:

 

[ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+150 date

Wed Jul 22 12:27:15 EDT 2009

 

 

Gives me incorrect date:

[ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+172 date

Tue Jul 28 18:27:09 GMT 2009

 

Basically I cannot go back more than 6 days...

 

Best,

Paul

 

___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: Bug report for date

2009-07-28 Thread Bob Proulx
Paul Grinberg wrote:
 Gives me correct date:
 [ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+150 date
 Wed Jul 22 12:27:15 EDT 2009
 
 Gives me incorrect date:
 [ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+172 date
 Tue Jul 28 18:27:09 GMT 2009
 
 Basically I cannot go back more than 6 days...

You have specified an invalid timezone.  Timezones are only defined
from 0 through 23 hours 59 seconds which is sufficient to define all
existing timezones.  Please see the GNU C manual for a complete
specification of the timezone using the TZ variable.

  http://www.gnu.org/software/coreutils/manual/libc.html#TZ-Variable

  The offset specifies the time value you must add to the local time
  to get a Coordinated Universal Time value.  It has syntax like
  [+|-]hh[:mm[:ss]].  This is positive if the local time zone is west
  of the Prime Meridian and negative if it is east.  The hour must be
  between 0 and 23, and the minute and seconds between 0 and 59.

If you are trying to do math calculations using date then it is better
to use date's relative time feature.

  $ date -R --date=-14 days
  Tue, 14 Jul 2009 17:04:43 -0600

Bob


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: Bug report for date

2009-07-28 Thread Philip Rowlands

On Tue, 28 Jul 2009, Paul Grinberg wrote:


Gives me correct date:

[ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+150 date
Wed Jul 22 12:27:15 EDT 2009

Gives me incorrect date:
[ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+172 date
Tue Jul 28 18:27:09 GMT 2009

Basically I cannot go back more than 6 days...


According to the POSIX/glibc definition of TZ:
http://www.opengroup.org/onlinepubs/95399/basedefs/xbd_chap08.html
http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html

the hour offset must be between 0 and 24. In other words, the examples 
above are undefined by the standards. Why are you trying to use TZ to 
concoct multi-day offsets?



Cheers,
Phil


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


RE: Bug report for date

2009-07-28 Thread Philip Rowlands

On Tue, 28 Jul 2009, Paul Grinberg wrote:


Shell script for SolarisIt can go future as long as I want, but past
only 6 days

http://www.isrcomputing.com/index.php?option=com_contentview=articleid=125:unix-shell-script-to-calculate-date-in-the-future-and-in-the-pastcatid=38:technology-tipsItemid=82


That script is using (/abusing) TZ beyond its stated purpose. As Bob 
suggests, GNU date can perform date calculations with relative offsets, 
e.g.


$ date -d 'now + 12 days'
Mon Aug 10 00:55:32 BST 2009


Cheers,
Phil



___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


RE: Bug report for date

2009-07-28 Thread Paul Grinberg
Bob,

Thank you for your reply. You are right, I am trying to calculate time
backwardsit only allows 6 days back...i need 7 :) the whole week :)

Unfortunately in solaris it does not work :(((

# date -R --date=-14 days
date: illegal option -- R
date: illegal option -- date=-14 days
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]

Thanks,
Paul


-Original Message-
From: Bob Proulx [mailto:b...@proulx.com] 
Sent: Tuesday, July 28, 2009 7:08 PM
To: Paul Grinberg
Cc: bug-coreutils@gnu.org
Subject: Re: Bug report for date

Paul Grinberg wrote:
 Gives me correct date:
 [ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+150 date
 Wed Jul 22 12:27:15 EDT 2009
 
 Gives me incorrect date:
 [ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+172 date
 Tue Jul 28 18:27:09 GMT 2009
 
 Basically I cannot go back more than 6 days...

You have specified an invalid timezone.  Timezones are only defined
from 0 through 23 hours 59 seconds which is sufficient to define all
existing timezones.  Please see the GNU C manual for a complete
specification of the timezone using the TZ variable.

  http://www.gnu.org/software/coreutils/manual/libc.html#TZ-Variable

  The offset specifies the time value you must add to the local time
  to get a Coordinated Universal Time value.  It has syntax like
  [+|-]hh[:mm[:ss]].  This is positive if the local time zone is west
  of the Prime Meridian and negative if it is east.  The hour must be
  between 0 and 23, and the minute and seconds between 0 and 59.

If you are trying to do math calculations using date then it is better
to use date's relative time feature.

  $ date -R --date=-14 days
  Tue, 14 Jul 2009 17:04:43 -0600

Bob


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


RE: Bug report for date

2009-07-28 Thread Paul Grinberg
Shell script for SolarisIt can go future as long as I want, but past
only 6 days

http://www.isrcomputing.com/index.php?option=com_contentview=articleid
=125:unix-shell-script-to-calculate-date-in-the-future-and-in-the-pastc
atid=38:technology-tipsItemid=82


Best,
Paul


-Original Message-
From: Philip Rowlands [mailto:p...@doc.ic.ac.uk] 
Sent: Tuesday, July 28, 2009 7:40 PM
To: Paul Grinberg
Cc: bug-coreutils@gnu.org
Subject: Re: Bug report for date

On Tue, 28 Jul 2009, Paul Grinberg wrote:

 Gives me correct date:

 [ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+150 date
 Wed Jul 22 12:27:15 EDT 2009

 Gives me incorrect date:
 [ctpsmg11-dcdhealth@/opt/app/dcdhealth] # TZ=EDT+172 date
 Tue Jul 28 18:27:09 GMT 2009

 Basically I cannot go back more than 6 days...

According to the POSIX/glibc definition of TZ:
http://www.opengroup.org/onlinepubs/95399/basedefs/xbd_chap08.html
http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html

the hour offset must be between 0 and 24. In other words, the examples 
above are undefined by the standards. Why are you trying to use TZ to 
concoct multi-day offsets?


Cheers,
Phil


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


RE: Bug report for date

2009-07-28 Thread Paul Grinberg
Phil,

 As I said...it is a workaround, since ins Solaris you cannot execute
that command:

# date -R --date=-14 days
date: illegal option -- R
date: illegal option -- date=-14 days
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]


Best,
Paul


-Original Message-
From: Philip Rowlands [mailto:p...@doc.ic.ac.uk] 
Sent: Tuesday, July 28, 2009 7:56 PM
To: Paul Grinberg
Cc: bug-coreutils@gnu.org
Subject: RE: Bug report for date

On Tue, 28 Jul 2009, Paul Grinberg wrote:

 Shell script for SolarisIt can go future as long as I want, but
past
 only 6 days


http://www.isrcomputing.com/index.php?option=com_contentview=articleid
=125:unix-shell-script-to-calculate-date-in-the-future-and-in-the-pastc
atid=38:technology-tipsItemid=82

That script is using (/abusing) TZ beyond its stated purpose. As Bob 
suggests, GNU date can perform date calculations with relative offsets, 
e.g.

$ date -d 'now + 12 days'
Mon Aug 10 00:55:32 BST 2009


Cheers,
Phil



___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: Bug report for date

2009-07-28 Thread Bob Proulx
Paul Grinberg wrote:
 Thank you for your reply. You are right, I am trying to calculate time
 backwardsit only allows 6 days back...i need 7 :) the whole week :)

 Unfortunately in solaris it does not work :(((

Well, this is the mailing list for the GNU system's date and so you
wouldn't expect us to suggest anything other than that perhaps you
might consider switching to the GNU system.  It works there!  :-)

 # date -R --date=-14 days
 date: illegal option -- R
 date: illegal option -- date=-14 days
 usage:  date [-u] mmddHHMM[[cc]yy][.SS]
 date [-u] [+format]
 date -a [-]sss[.fff]

Well, that isn't the GNU date so there isn't anything that we can say
here that will help you there.  Good luck!

Do you have Perl, Python or Ruby?  You might try doing date
calculations using Perl and the Date::Calc library.

Bob


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


RE: Bug report for date

2009-07-28 Thread Paul Grinberg
Perl is my friend :)))


Best,
Paul


-Original Message-
From: Bob Proulx [mailto:b...@proulx.com] 
Sent: Tuesday, July 28, 2009 8:29 PM
To: Paul Grinberg
Cc: bug-coreutils@gnu.org
Subject: Re: Bug report for date

Paul Grinberg wrote:
 Thank you for your reply. You are right, I am trying to calculate time
 backwardsit only allows 6 days back...i need 7 :) the whole week
:)

 Unfortunately in solaris it does not work :(((

Well, this is the mailing list for the GNU system's date and so you
wouldn't expect us to suggest anything other than that perhaps you
might consider switching to the GNU system.  It works there!  :-)

 # date -R --date=-14 days
 date: illegal option -- R
 date: illegal option -- date=-14 days
 usage:  date [-u] mmddHHMM[[cc]yy][.SS]
 date [-u] [+format]
 date -a [-]sss[.fff]

Well, that isn't the GNU date so there isn't anything that we can say
here that will help you there.  Good luck!

Do you have Perl, Python or Ruby?  You might try doing date
calculations using Perl and the Date::Calc library.

Bob


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils