File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,8 @@ test('basic', () => {
126
126
`"Cannot parse "undefined" into LocalTime"` ,
127
127
)
128
128
129
+ expect ( localTime ( 0 ) . toISODateTime ( ) ) . toMatchInlineSnapshot ( `"1970-01-01T00:00:00"` )
130
+
129
131
expect ( localTime . getTimezone ( ) ) . toBe ( 'UTC' )
130
132
expect ( localTime . isTimezoneValid ( 'Europe/Stockholm' ) ) . toBe ( true )
131
133
expect ( localTime . isTimezoneValid ( 'Europe/Stockholm2' ) ) . toBe ( false )
Original file line number Diff line number Diff line change @@ -714,7 +714,6 @@ class LocalTimeFactory {
714
714
* Returns null if invalid
715
715
*/
716
716
parseOrNull ( d : LocalTimeInputNullable ) : LocalTime | null {
717
- if ( ! d ) return null
718
717
if ( d instanceof LocalTime ) return d
719
718
720
719
let date
@@ -723,6 +722,9 @@ class LocalTimeFactory {
723
722
date = d
724
723
} else if ( typeof d === 'number' ) {
725
724
date = new Date ( d * 1000 )
725
+ } else if ( ! d ) {
726
+ // This check is after checking the number, to support `0`
727
+ return null
726
728
} else if ( typeof ( d as any ) !== 'string' ) {
727
729
// unexpected type, e.g Function or something
728
730
return null
You can’t perform that action at this time.
0 commit comments