Project

General

Profile

Bug #12833

Updated by jonwolski (Jon Wolski) over 5 years ago

## Expected 

 `DateTime.iso8601('2016-10')` expected: DateTime.iso8601('2016-10') parses the input string as four-digit year and two-digit month. 

 ## Actual 

 `DateTime.iso8601('2016-10')` actual: DateTime.iso8601('2016-10') parses the input string as four-digit year and two-digit day-of-month.  

 ## Steps steps to reproduce reproduce: 

 ```sh 
 $ ruby -v -r date -e "puts DateTime.iso8601('2016-10').iso8601" 
 ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] 
 2016-01-10T00:00:00+00:00 
 ``` 

 ## More details 


 ```sh Here's some more background: 
 $ ruby -r date -e "puts Date._iso8601('2016-10')" 
 {:mday=>10, :year=>2016} 
 $ ruby -r date -e "puts Date._iso8601('2016-101')" 
 {:yday=>101, :year=>2016} 
 ``` 

 This seems to suggest that the "10" is parsed as day-of-month (`:mday`) in the case of "YYYY-DD", but "101" is parsed as day-of-year (`:yday`) in the case of "YYYY-DDD". (The 3-digit day part _does_ in fact represent the day-of-year; that feature is correct.)

Back