File tree 1 file changed +13
-9
lines changed
1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -23,17 +23,21 @@ const shortenAmPm = (text: string): string => {
23
23
24
24
const removeLeadingZero = ( text : string ) : string => text . replace ( / ^ 0 / , "" ) ;
25
25
26
- export const createFormatTime =
26
+ export const formatTime = ( date : Date , locale ?: string ) : string => {
27
+ return removeLeadingZero (
28
+ shortenAmPm (
29
+ date . toLocaleTimeString ( locale , {
30
+ hour : "2-digit" ,
31
+ minute : "2-digit" ,
32
+ } ) || ""
33
+ )
34
+ ) ;
35
+ } ;
36
+
37
+ const createFormatTime =
27
38
( locale ?: string ) =>
28
39
( date : Date ) : string =>
29
- removeLeadingZero (
30
- shortenAmPm (
31
- date . toLocaleTimeString ( locale , {
32
- hour : "2-digit" ,
33
- minute : "2-digit" ,
34
- } ) || ""
35
- )
36
- ) ;
40
+ formatTime ( date , locale ) ;
37
41
38
42
const getNavigatorLanguage = ( ) : string => {
39
43
if ( typeof window === "undefined" ) {
You can’t perform that action at this time.
0 commit comments