Home parsing inconsistency of date -d
Reply: 1

parsing inconsistency of date -d

Deian
1#
Deian Published in 2018-01-12 23:07:43Z

How is the date parser working?

date -d "2010-08-12 05:30:30.102 AM + 0 months"
Thu Aug 12 05:30:30 EDT 2010

but

date -d "2010-08-12 05:30:30.102 + 0 months"
Thu Aug 12 01:30:30 EDT 2010
sytech
2#
sytech Reply to 2018-01-12 23:39:30Z

It seems to be the case that the + 0 is being interpreted as a UTC offset when AM is not included. However, when AM is included, it's no longer ambiguous whether or not the + 0 is for the offset or if it's belonging to months because UTC offsets are only valid when 24-hour time is used.

In the former case, months alone is being interpreted as + 1 months (at least in some versions of date) as ghoti mentioned in the comments.

Also consider that date -d "2010-08-12 05:30:30 +0" is an acceptable format. However date -d "2010-08-12 05:30:30 AM +0" is invalid because UTC offsets can't be used when AM is present.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307188 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO