@@ -934,10 +934,6 @@ export class DateTime extends AbstractDate {
934934 return this . toString ( ) ;
935935 }
936936
937- _pad ( num : number ) {
938- return String ( '0' + num ) . slice ( - 2 ) ;
939- }
940-
941937 toString ( ) {
942938 if ( this . isTime ( ) ) {
943939 return this . toStringTime ( ) ;
@@ -949,13 +945,13 @@ export class DateTime extends AbstractDate {
949945 toStringTime ( ) {
950946 let str = '' ;
951947 if ( this . hour != null ) {
952- str += this . _pad ( this . hour ) ;
948+ str += String ( this . hour ) . padStart ( 2 , '0' ) ;
953949 if ( this . minute != null ) {
954- str += ':' + this . _pad ( this . minute ) ;
950+ str += ':' + String ( this . minute ) . padStart ( 2 , '0' ) ;
955951 if ( this . second != null ) {
956- str += ':' + this . _pad ( this . second ) ;
952+ str += ':' + String ( this . second ) . padStart ( 2 , '0' ) ;
957953 if ( this . millisecond != null ) {
958- str += '.' + String ( '00' + this . millisecond ) . slice ( - 3 ) ;
954+ str += '.' + String ( this . millisecond ) . padStart ( 3 , '0' ) ;
959955 }
960956 }
961957 }
@@ -967,19 +963,19 @@ export class DateTime extends AbstractDate {
967963 toStringDateTime ( ) {
968964 let str = '' ;
969965 if ( this . year != null ) {
970- str += this . year ;
966+ str += String ( this . year ) . padStart ( 4 , '0' ) ;
971967 if ( this . month != null ) {
972- str += '-' + this . _pad ( this . month ) ;
968+ str += '-' + String ( this . month ) . padStart ( 2 , '0' ) ;
973969 if ( this . day != null ) {
974- str += '-' + this . _pad ( this . day ) ;
970+ str += '-' + String ( this . day ) . padStart ( 2 , '0' ) ;
975971 if ( this . hour != null ) {
976- str += 'T' + this . _pad ( this . hour ) ;
972+ str += 'T' + String ( this . hour ) . padStart ( 2 , '0' ) ;
977973 if ( this . minute != null ) {
978- str += ':' + this . _pad ( this . minute ) ;
974+ str += ':' + String ( this . minute ) . padStart ( 2 , '0' ) ;
979975 if ( this . second != null ) {
980- str += ':' + this . _pad ( this . second ) ;
976+ str += ':' + String ( this . second ) . padStart ( 2 , '0' ) ;
981977 if ( this . millisecond != null ) {
982- str += '.' + String ( '00' + this . millisecond ) . slice ( - 3 ) ;
978+ str += '.' + String ( this . millisecond ) . padStart ( 3 , '0' ) ;
983979 }
984980 }
985981 }
@@ -991,9 +987,9 @@ export class DateTime extends AbstractDate {
991987 if ( str . indexOf ( 'T' ) !== - 1 && this . timezoneOffset != null ) {
992988 str += this . timezoneOffset < 0 ? '-' : '+' ;
993989 const offsetHours = Math . floor ( Math . abs ( this . timezoneOffset ) ) ;
994- str += this . _pad ( offsetHours ) ;
990+ str += String ( offsetHours ) . padStart ( 2 , '0' ) ;
995991 const offsetMin = ( Math . abs ( this . timezoneOffset ) - offsetHours ) * 60 ;
996- str += ':' + this . _pad ( offsetMin ) ;
992+ str += ':' + String ( offsetMin ) . padStart ( 2 , '0' ) ;
997993 }
998994
999995 return str ;
@@ -1218,7 +1214,7 @@ export class Date extends AbstractDate {
12181214 toString ( ) {
12191215 let str = '' ;
12201216 if ( this . year != null ) {
1221- str += this . year . toString ( ) ;
1217+ str += this . year . toString ( ) . padStart ( 4 , '0' ) ;
12221218 if ( this . month != null ) {
12231219 str += '-' + this . month . toString ( ) . padStart ( 2 , '0' ) ;
12241220 if ( this . day != null ) {
0 commit comments