Fix parsing year when using Y2K compatibility formats
...like `%(Y1970)` and `%(Y2000)`. This fixes regression tests.
--- a/Date.st Tue Jun 01 20:19:13 2021 +0100
+++ b/Date.st Tue Jun 08 22:22:11 2021 +0100
@@ -2,6 +2,7 @@
"
COPYRIGHT (c) 1989 by Claus Gittinger
+ COPYRIGHT (c) 2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -28,6 +29,7 @@
copyright
"
COPYRIGHT (c) 1989 by Claus Gittinger
+ COPYRIGHT (c) 2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -820,6 +822,7 @@
"
! !
+
!Date class methodsFor:'Compatibility-Dolphin'!
newDay:day monthIndex:month year:year
@@ -2005,7 +2008,7 @@
|dayName monthName day month year format string dayOfYear|
- format := fmt.
+ format := fmt asLowercase.
string := str throughAnyForWhich:[:ch | ch isNationalAlphaNumeric].
((format sameAs:'dayName') or:[format sameAs:'shortDayName']) ifTrue:[
@@ -2055,6 +2058,18 @@
^ #year -> year
].
+ format = 'y1970' ifTrue:[
+ "shift YY into 1970..2069; for 2k support of old date strings"
+ year := Integer readFrom:string.
+ year < 100 ifTrue:[
+ year < 70 ifTrue:[
+ ^ #year -> (year + 2000)
+ ].
+ ^ #year -> (year + 1900)
+ ].
+ ^ #year -> year
+ ].
+
format = 'y1980' ifTrue:[
"shift YY into 1980..2079; for 2k support of old date strings"
year := Integer readFrom:string.
@@ -2067,6 +2082,16 @@
^ #year -> year
].
+ format = 'y2000' ifTrue:[
+ "shift YY into 2000..2099; for 2k support of old date strings"
+ year := Integer readFrom:string.
+ year < 100 ifTrue:[
+ ^ #year -> (year + 2000)
+ ].
+ ^ #year -> year
+ ].
+
+
(format = 'Y') ifTrue:[
"shift YY into 1970..2069; for 2k support of old date strings"
year := Integer readFrom:string.
@@ -2093,6 +2118,8 @@
].
self error:'unknown format specifier: ',format
+
+ "Modified: / 08-06-2021 / 22:19:29 / Jan Vrany <jan.vrany@labware.com>"
! !
!Date class methodsFor:'private-instance creation'!
@@ -3274,7 +3301,6 @@
! !
-
!Date methodsFor:'obsolete'!
asAbsoluteTime
@@ -3345,7 +3371,6 @@
^ self addDays:days
! !
-
!Date methodsFor:'printing & storing'!
addPrintBindingsTo:aDictionary
@@ -3767,6 +3792,11 @@
version_CVS
^ '$Header$'
+!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
! !