diff -r 6184d4210c89 -r 621525712675 Date.st --- a/Date.st Sat Jun 06 12:41:52 2015 +0200 +++ b/Date.st Sat Jun 06 12:50:46 2015 +0200 @@ -490,9 +490,11 @@ 2 month position (1..3) 3 year position (1..3) or a formatString (see printing instance protocol). - For now %d, %m, %monthName, %shortMonthName, %y, %y1900, %y2000, %y1950 and %y1980 are supported in the formatString. - y1900 converts 2-digit year YY into 19YY, y2000 into 20YY. - y1950 and y1980 are special; if the year is below 50/80, it is converted to 20YY, otherwise to 19YY. + For now %d, %m, %monthName, %shortMonthName, %y, %Y, %y1900, %y2000, %y1950 and %y1980 are supported in the formatString. + y1900 converts 2-digit year YY into 19YY, + y2000 into 20YY. + y1950, y1980 and Y are special; + if the year is below 50/80/70, it is converted to 20YY, otherwise to 19YY. The formatString can have any of these characters '-.:,;/' as separator. The format may be preceeded by a single numeric length (as in %2d) to specify how many characters to read. @@ -612,6 +614,10 @@ Date readFrom:'300180' printFormat:'%2d%2m%2y' onError:'fail' Date readFrom:'300170' printFormat:'%2d%2m%2y' onError:'fail' - gives 2070 as year + Date readFrom:'300170' printFormat:'%2d%2m%2Y' onError:'fail' - gives 1970 as year + Date readFrom:'300169' printFormat:'%2d%2m%2y' onError:'fail' - gives 2069 as year + Date readFrom:'300169' printFormat:'%2d%2m%2Y' onError:'fail' - gives 2069 as year + Date readFrom:'300170' printFormat:'%2d%2m%2(y1950)' onError:'fail' - gives 1970 as year Date readFrom:'300170' printFormat:'%2d%2m%2(y1980)' onError:'fail' - gives 2070 as year Date readFrom:'300181' printFormat:'%2d%2m%2(y1980)' onError:'fail' - gives 1981 as year @@ -640,9 +646,9 @@ or a formatString (see printing instance protocol). All of the %-formats as in the printString are supported here. (i.e. %d, %m and %y, %shortMonthName and %monthName) - In addition, %y1900, %y2000, %y1950 and %y1980 are supported: + In addition, %Y, %y1900, %y2000, %y1950 and %y1980 are supported: y1900 converts 2-digit year YY into 19YY, y2000 into 20YY. - y1950 and y1980 are special; if the year is below 50/80, it is converted to 20YY, otherwise to 19YY. + y1950, y1980 and Y are special; if the year is below 50/80/70, it is converted to 20YY, otherwise to 19YY. TODO: make this a general feature of all DateAndTime classes. " @@ -1989,12 +1995,12 @@ dayName := string. ^ nil. ]. - (format sameAs:'d') ifTrue:[ + ((format sameAs:'d') or:[format sameAs:'day']) ifTrue:[ day := Integer readFrom:string. ^ #day -> day ]. - (format sameAs:'m') ifTrue:[ + ((format sameAs:'m') or:[format sameAs:'month']) ifTrue:[ month := Integer readFrom:string. ^ #month -> month ]. @@ -2043,7 +2049,19 @@ ^ #year -> year ]. - (format sameAs: 'y') ifTrue:[ + (format = 'Y') 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 = 'y') or:[format sameAs:'year']) ifTrue:[ year := Integer readFrom:string. year < 100 ifTrue:[ ^ #year -> (year + 2000) @@ -3710,11 +3728,11 @@ !Date class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.172 2015-06-06 10:26:43 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.173 2015-06-06 10:50:46 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.172 2015-06-06 10:26:43 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.173 2015-06-06 10:50:46 cg Exp $' ! !