@@ -2,7 +2,7 @@ import type { CompiledObject } from './compile.ts';
22import type { DateLike } from './datetime.ts' ;
33import type { Locale } from './locale.ts' ;
44import type { Numeral } from './numeral.ts' ;
5- import type { TimeZone } from './timezone .ts' ;
5+ import type { TimeZone } from './zone .ts' ;
66
77export interface FormatterPluginOptions {
88 /**
@@ -31,12 +31,12 @@ export interface FormatterPluginOptions {
3131 */
3232 calendar : 'buddhist' | 'gregory' ;
3333
34- /**
35- * The time zone to use for formatting dates and times.
36- * This can be a specific time zone object or 'UTC' to use Coordinated Universal Time.
37- * If not specified, it defaults to undefined, which means the local time zone will be used.
38- */
39- timeZone : TimeZone | 'UTC' | undefined ;
34+ /**
35+ * The time zone to use for formatting dates and times.
36+ * This can be a specific time zone object, an IANA time zone name, or 'UTC' to use Coordinated Universal Time.
37+ * If not specified, it defaults to undefined, which means the local time zone will be used.
38+ */
39+ timeZone : TimeZone | string | undefined ;
4040
4141 /**
4242 * The locale to use for formatting dates and times.
@@ -72,12 +72,12 @@ class DefaultFormatter extends FormatterPlugin {
7272
7373 MMMM ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
7474 const list = options . locale . getMonthList ( { style : 'long' , compiledObj } ) ;
75- return list [ d . getMonth ( ) ] || '' ;
75+ return list [ d . getMonth ( ) ] ?? '' ;
7676 }
7777
7878 MMM ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
7979 const list = options . locale . getMonthList ( { style : 'short' , compiledObj } ) ;
80- return list [ d . getMonth ( ) ] || '' ;
80+ return list [ d . getMonth ( ) ] ?? '' ;
8181 }
8282
8383 MM ( d : DateLike ) {
@@ -106,22 +106,22 @@ class DefaultFormatter extends FormatterPlugin {
106106
107107 AA ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
108108 const list = options . locale . getMeridiemList ( { style : 'long' , compiledObj, case : 'uppercase' } ) ;
109- return list [ + ( d . getHours ( ) > 11 ) ] || '' ;
109+ return list [ + ( d . getHours ( ) > 11 ) ] ?? '' ;
110110 }
111111
112112 A ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
113113 const list = options . locale . getMeridiemList ( { style : 'short' , compiledObj, case : 'uppercase' } ) ;
114- return list [ + ( d . getHours ( ) > 11 ) ] || '' ;
114+ return list [ + ( d . getHours ( ) > 11 ) ] ?? '' ;
115115 }
116116
117117 aa ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
118118 const list = options . locale . getMeridiemList ( { style : 'long' , compiledObj, case : 'lowercase' } ) ;
119- return list [ + ( d . getHours ( ) > 11 ) ] || '' ;
119+ return list [ + ( d . getHours ( ) > 11 ) ] ?? '' ;
120120 }
121121
122122 a ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
123123 const list = options . locale . getMeridiemList ( { style : 'short' , compiledObj, case : 'lowercase' } ) ;
124- return list [ + ( d . getHours ( ) > 11 ) ] || '' ;
124+ return list [ + ( d . getHours ( ) > 11 ) ] ?? '' ;
125125 }
126126
127127 hh ( d : DateLike , options : FormatterPluginOptions ) {
@@ -162,17 +162,17 @@ class DefaultFormatter extends FormatterPlugin {
162162
163163 dddd ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
164164 const list = options . locale . getDayOfWeekList ( { style : 'long' , compiledObj } ) ;
165- return list [ d . getDay ( ) ] || '' ;
165+ return list [ d . getDay ( ) ] ?? '' ;
166166 }
167167
168168 ddd ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
169169 const list = options . locale . getDayOfWeekList ( { style : 'short' , compiledObj } ) ;
170- return list [ d . getDay ( ) ] || '' ;
170+ return list [ d . getDay ( ) ] ?? '' ;
171171 }
172172
173173 dd ( d : DateLike , options : FormatterPluginOptions , compiledObj : CompiledObject ) {
174174 const list = options . locale . getDayOfWeekList ( { style : 'narrow' , compiledObj } ) ;
175- return list [ d . getDay ( ) ] || '' ;
175+ return list [ d . getDay ( ) ] ?? '' ;
176176 }
177177
178178 Z ( d : DateLike ) {
0 commit comments