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';
2727import { groupBy , sortBy } from 'lodash' ;
2828import Image from 'next/image' ;
2929import { extend } from 'dayjs' ;
30+ import { isUSCitizen } from './helpers/isuscitizen.utils' ;
3031extend ( isSameOrAfter ) ;
3132extend ( isSameOrBefore ) ;
3233
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+
3342export const days = [
3443 'Monday' ,
3544 'Tuesday' ,
@@ -91,7 +100,7 @@ export const DayView = () => {
91100 . startOf ( 'day' )
92101 . add ( option [ 0 ] . time , 'minute' )
93102 . local ( )
94- . format ( ' HH:mm' ) }
103+ . format ( isUSCitizen ( ) ? "hh:mm A" : " HH:mm" ) }
95104 </ div >
96105 < div
97106 key = { option [ 0 ] . time }
@@ -140,7 +149,8 @@ export const WeekView = () => {
140149 { hours . map ( ( hour ) => (
141150 < Fragment key = { hour } >
142151 < 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 ) }
144154 </ div >
145155 { days . map ( ( day , indexDay ) => (
146156 < 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
33import clsx from 'clsx' ;
44import dayjs from 'dayjs' ;
55import { useCallback } from 'react' ;
6+ import { isUSCitizen } from './helpers/isuscitizen.utils' ;
67
78export const Filters = ( ) => {
89 const week = useCalendar ( ) ;
@@ -12,30 +13,30 @@ export const Filters = () => {
1213 . year ( week . currentYear )
1314 . isoWeek ( week . currentWeek )
1415 . day ( week . currentDay )
15- . format ( 'DD/MM/YYYY' )
16+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' )
1617 : week . display === 'week'
1718 ? dayjs ( )
1819 . year ( week . currentYear )
1920 . isoWeek ( week . currentWeek )
2021 . startOf ( 'isoWeek' )
21- . format ( 'DD/MM/YYYY' ) +
22+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' ) +
2223 ' - ' +
2324 dayjs ( )
2425 . year ( week . currentYear )
2526 . isoWeek ( week . currentWeek )
2627 . endOf ( 'isoWeek' )
27- . format ( 'DD/MM/YYYY' )
28+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' )
2829 : dayjs ( )
2930 . year ( week . currentYear )
3031 . month ( week . currentMonth )
3132 . startOf ( 'month' )
32- . format ( 'DD/MM/YYYY' ) +
33+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' ) +
3334 ' - ' +
3435 dayjs ( )
3536 . year ( week . currentYear )
3637 . month ( week . currentMonth )
3738 . endOf ( 'month' )
38- . format ( 'DD/MM/YYYY' ) ;
39+ . format ( isUSCitizen ( ) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' ) ;
3940
4041 const setDay = useCallback ( ( ) => {
4142 week . setFilters ( {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import dayjs from 'dayjs';
33import { Calendar , TimeInput } from '@mantine/dates' ;
44import { useClickOutside } from '@mantine/hooks' ;
55import { Button } from '@gitroom/react/form/button' ;
6+ import { isUSCitizen } from './isuscitizen.utils' ;
67
78export const DatePicker : FC < {
89 date : dayjs . Dayjs ;
@@ -39,7 +40,7 @@ export const DatePicker: FC<{
3940 onClick = { changeShow }
4041 ref = { ref }
4142 >
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 >
4344 < div className = "cursor-pointer" >
4445 < svg
4546 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