@@ -17,10 +17,6 @@ import {
1717 UserText ,
1818} from "./subs" ;
1919
20- /**
21- * These types help ensure we don't misspell them anywhere. They will be
22- * removed during build.
23- */
2420const months = [
2521 "January" ,
2622 "February" ,
@@ -35,7 +31,6 @@ const months = [
3531 "November" ,
3632 "December" ,
3733] as const ;
38- type Months = ( typeof months ) [ number ] ;
3934
4035const days = [
4136 "Sunday" ,
@@ -46,7 +41,6 @@ const days = [
4641 "Friday" ,
4742 "Saturday" ,
4843] as const ;
49- type Days = ( typeof days ) [ number ] ;
5044
5145/**
5246 * Takes an integer and returns a string left padded with
@@ -60,13 +54,15 @@ function padWithZeros(int: number): string {
6054 * Adds suffix to day, so 16 becomes 16th.
6155 */
6256function suffix ( int : number ) : string {
63- return int % 10 === 1 && int !== 11
64- ? `${ int } st`
65- : int % 10 === 2 && int !== 12
66- ? `${ int } nd`
67- : int % 10 === 3 && int !== 13
68- ? `${ int } rd`
69- : `${ int } th` ;
57+ const suf =
58+ int % 10 === 1 && int !== 11
59+ ? "st"
60+ : int % 10 === 2 && int !== 12
61+ ? "nd"
62+ : int % 10 === 3 && int !== 13
63+ ? "rd"
64+ : "th" ;
65+ return `${ int } ${ suf } ` ;
7066}
7167
7268/**
@@ -99,9 +95,9 @@ export default function compiler(
9995 break ;
10096 }
10197
102- switch ( token . t ) {
98+ switch ( token [ 0 ] ) {
10399 case UserText :
104- compiled += token . v ;
100+ compiled += token [ 1 ] ;
105101 break ;
106102
107103 case Day :
@@ -130,7 +126,7 @@ export default function compiler(
130126 break ;
131127
132128 case PartialYear :
133- compiled += `${ year } ` . slice ( 2 ) ;
129+ compiled += `${ year % 100 } ` ;
134130 break ;
135131
136132 case DayOfTheWeek :
@@ -143,7 +139,7 @@ export default function compiler(
143139
144140 case Hour :
145141 {
146- const hour = hours === 0 || hours === 12 ? 12 : hours % 12 ;
142+ const hour = hours % 12 || 12 ;
147143 compiled += options . padHours ? padWithZeros ( hour ) : hour ;
148144 }
149145 break ;
0 commit comments