Home parsing inconsistency of date -d

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