diff options
author | Anton Tananaev <anton@traccar.org> | 2022-11-06 17:00:03 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-11-06 17:00:03 -0800 |
commit | a9c8b1b6c513257a5fd69cf00992d4fec59d6069 (patch) | |
tree | b2fa1bd33ae8766affb4ac1cfdba2dde5a9a54de /modern/src/settings | |
parent | 4d6d5eca8c6ee8c43340d18d323816885edeb9da (diff) | |
download | trackermap-web-a9c8b1b6c513257a5fd69cf00992d4fec59d6069.tar.gz trackermap-web-a9c8b1b6c513257a5fd69cf00992d4fec59d6069.tar.bz2 trackermap-web-a9c8b1b6c513257a5fd69cf00992d4fec59d6069.zip |
Respect 12 hour time
Diffstat (limited to 'modern/src/settings')
-rw-r--r-- | modern/src/settings/CalendarPage.js | 10 | ||||
-rw-r--r-- | modern/src/settings/UsersPage.js | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/modern/src/settings/CalendarPage.js b/modern/src/settings/CalendarPage.js index 81f0021d..17848484 100644 --- a/modern/src/settings/CalendarPage.js +++ b/modern/src/settings/CalendarPage.js @@ -13,7 +13,7 @@ import { useTranslation } from '../common/components/LocalizationProvider'; import SettingsMenu from './components/SettingsMenu'; import { prefixString } from '../common/util/stringUtils'; -const formatTime = (time) => { +const formatCalendarTime = (time) => { const tzid = Intl.DateTimeFormat().resolvedOptions().timeZone; return `TZID=${tzid}:${time.locale('en').format('YYYYMMDDTHHmmss')}`; }; @@ -47,8 +47,8 @@ const simpleCalendar = () => window.btoa([ 'PRODID:-//Traccar//NONSGML Traccar//EN', 'BEGIN:VEVENT', 'UID:00000000-0000-0000-0000-000000000000', - `DTSTART;${formatTime(moment())}`, - `DTEND;${formatTime(moment().add(1, 'hours'))}`, + `DTSTART;${formatCalendarTime(moment())}`, + `DTEND;${formatCalendarTime(moment().add(1, 'hours'))}`, 'RRULE:FREQ=DAILY', 'SUMMARY:Event', 'END:VEVENT', @@ -133,7 +133,7 @@ const CalendarPage = () => { type="datetime-local" value={moment(lines[5].slice(-15)).locale('en').format(moment.HTML5_FMT.DATETIME_LOCAL)} onChange={(e) => { - const time = formatTime(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL)); + const time = formatCalendarTime(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL)); setItem({ ...item, data: updateCalendar(lines, 5, `DTSTART;${time}`) }); }} /> @@ -142,7 +142,7 @@ const CalendarPage = () => { type="datetime-local" value={moment(lines[6].slice(-15)).locale('en').format(moment.HTML5_FMT.DATETIME_LOCAL)} onChange={(e) => { - const time = formatTime(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL)); + const time = formatCalendarTime(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL)); setItem({ ...item, data: updateCalendar(lines, 6, `DTEND;${time}`) }); }} /> diff --git a/modern/src/settings/UsersPage.js b/modern/src/settings/UsersPage.js index bdebb1bb..6cb10d25 100644 --- a/modern/src/settings/UsersPage.js +++ b/modern/src/settings/UsersPage.js @@ -14,6 +14,7 @@ import CollectionActions from './components/CollectionActions'; import TableShimmer from '../common/components/TableShimmer'; import { useAdministrator } from '../common/util/permissions'; import SearchHeader, { filterByKeyword } from './components/SearchHeader'; +import { usePreference } from '../common/util/preferences'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -28,6 +29,8 @@ const UsersPage = () => { const admin = useAdministrator(); + const hours12 = usePreference('twelveHourFormat'); + const [timestamp, setTimestamp] = useState(Date.now()); const [items, setItems] = useState([]); const [searchKeyword, setSearchKeyword] = useState(''); @@ -83,7 +86,7 @@ const UsersPage = () => { <TableCell>{item.email}</TableCell> <TableCell>{formatBoolean(item.administrator, t)}</TableCell> <TableCell>{formatBoolean(item.disabled, t)}</TableCell> - <TableCell>{formatTime(item.expirationTime, 'YYYY-MM-DD')}</TableCell> + <TableCell>{formatTime(item.expirationTime, 'date', hours12)}</TableCell> <TableCell className={classes.columnAction} padding="none"> <CollectionActions itemId={item.id} |