File tree Expand file tree Collapse file tree 4 files changed +25
-8
lines changed
apps/frontend/src/components/launches Expand file tree Collapse file tree 4 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,18 @@ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
27
27
import { groupBy , sortBy } from 'lodash' ;
28
28
import Image from 'next/image' ;
29
29
import { extend } from 'dayjs' ;
30
+ import { isUSCitizen } from './helpers/isuscitizen.utils' ;
30
31
extend ( isSameOrAfter ) ;
31
32
extend ( isSameOrBefore ) ;
32
33
34
+ const convertTimeFormatBasedOnLocality = ( time : number ) => {
35
+ if ( isUSCitizen ( ) ) {
36
+ return `${ time === 12 ? 12 : time % 12 } :00 ${ time >= 12 ? "PM" : "AM" } `
37
+ } else {
38
+ return `${ time } :00`
39
+ }
40
+ }
41
+
33
42
export const days = [
34
43
'Monday' ,
35
44
'Tuesday' ,
@@ -91,7 +100,7 @@ export const DayView = () => {
91
100
. startOf ( 'day' )
92
101
. add ( option [ 0 ] . time , 'minute' )
93
102
. local ( )
94
- . format ( ' HH:mm' ) }
103
+ . format ( isUSCitizen ( ) ? "hh:mm A" : " HH:mm" ) }
95
104
</ div >
96
105
< div
97
106
key = { option [ 0 ] . time }
@@ -140,7 +149,8 @@ export const WeekView = () => {
140
149
{ hours . map ( ( hour ) => (
141
150
< Fragment key = { hour } >
142
151
< div className = "p-2 pr-4 bg-secondary text-center items-center justify-center flex" >
143
- { hour . toString ( ) . padStart ( 2 , '0' ) } :00
152
+ { /* {hour.toString().padStart(2, '0')}:00 */ }
153
+ { convertTimeFormatBasedOnLocality ( hour ) }
144
154
</ div >
145
155
{ days . map ( ( day , indexDay ) => (
146
156
< Fragment key = { `${ day } -${ hour } ` } >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { useCalendar } from '@gitroom/frontend/components/launches/calendar.cont
3
3
import clsx from 'clsx' ;
4
4
import dayjs from 'dayjs' ;
5
5
import { useCallback } from 'react' ;
6
+ import { isUSCitizen } from './helpers/isuscitizen.utils' ;
6
7
7
8
export const Filters = ( ) => {
8
9
const week = useCalendar ( ) ;
@@ -12,30 +13,30 @@ export const Filters = () => {
12
13
. year ( week . currentYear )
13
14
. isoWeek ( week . currentWeek )
14
15
. day ( week . currentDay )
15
- . format ( 'DD/MM/YYYY' )
16
+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' )
16
17
: week . display === 'week'
17
18
? dayjs ( )
18
19
. year ( week . currentYear )
19
20
. isoWeek ( week . currentWeek )
20
21
. startOf ( 'isoWeek' )
21
- . format ( 'DD/MM/YYYY' ) +
22
+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' ) +
22
23
' - ' +
23
24
dayjs ( )
24
25
. year ( week . currentYear )
25
26
. isoWeek ( week . currentWeek )
26
27
. endOf ( 'isoWeek' )
27
- . format ( 'DD/MM/YYYY' )
28
+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' )
28
29
: dayjs ( )
29
30
. year ( week . currentYear )
30
31
. month ( week . currentMonth )
31
32
. startOf ( 'month' )
32
- . format ( 'DD/MM/YYYY' ) +
33
+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' ) +
33
34
' - ' +
34
35
dayjs ( )
35
36
. year ( week . currentYear )
36
37
. month ( week . currentMonth )
37
38
. endOf ( 'month' )
38
- . format ( 'DD/MM/YYYY' ) ;
39
+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' ) ;
39
40
40
41
const setDay = useCallback ( ( ) => {
41
42
week . setFilters ( {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import dayjs from 'dayjs';
3
3
import { Calendar , TimeInput } from '@mantine/dates' ;
4
4
import { useClickOutside } from '@mantine/hooks' ;
5
5
import { Button } from '@gitroom/react/form/button' ;
6
+ import { isUSCitizen } from './isuscitizen.utils' ;
6
7
7
8
export const DatePicker : FC < {
8
9
date : dayjs . Dayjs ;
@@ -39,7 +40,7 @@ export const DatePicker: FC<{
39
40
onClick = { changeShow }
40
41
ref = { ref }
41
42
>
42
- < div className = "cursor-pointer" > { date . format ( 'DD/MM/YYYY HH:mm' ) } </ div >
43
+ < div className = "cursor-pointer" > { date . format ( isUSCitizen ( ) ? 'MM/DD/YYYY hh:mm A' : 'DD/MM/YYYY HH:mm' ) } </ div >
43
44
< div className = "cursor-pointer" >
44
45
< svg
45
46
xmlns = "http://www.w3.org/2000/svg"
Original file line number Diff line number Diff line change
1
+
2
+ export const isUSCitizen = ( ) => {
3
+ const userLanguage = navigator . language || navigator . languages [ 0 ] ;
4
+ return userLanguage . startsWith ( 'en-US' )
5
+ }
You can’t perform that action at this time.
0 commit comments