11import { styled } from "@mui/material" ;
22import Datepicker from "components/Datepicker" ;
33import Timepicker from "components/Timepicker" ;
4- import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb" ;
54import { useTranslation } from "i18n" ;
65import { COMMUNITIES } from "i18n/namespaces" ;
76import { Event } from "proto/events_pb" ;
87import { UseFormReturn } from "react-hook-form" ;
98import { Temporal } from "temporal-polyfill" ;
109import { theme } from "theme" ;
11- import { timestamp2Date } from "utils/date" ;
10+ import { timestampToPlainDateTime } from "utils/date" ;
1211import { timePattern } from "utils/validation" ;
1312
1413import { CreateEventData } from "./EventForm" ;
@@ -32,16 +31,6 @@ interface EventTimeChangerProps
3231 errors : UseFormReturn < CreateEventData > [ "formState" ] [ "errors" ] ;
3332}
3433
35- function toPlainDateTime (
36- timestamp : Timestamp . AsObject ,
37- ) : Temporal . PlainDateTime {
38- const legacyDate = timestamp2Date ( timestamp ) ;
39- const instant = Temporal . Instant . fromEpochMilliseconds ( legacyDate . getTime ( ) ) ;
40- // FIXME(#8064): Event times should be interpreted in their timezones.
41- const zoned = instant . toZonedDateTimeISO ( Temporal . Now . timeZoneId ( ) ) ;
42- return zoned . toPlainDateTime ( ) ;
43- }
44-
4534export default function EventTimeChanger ( {
4635 control,
4736 dirtyFields,
@@ -52,11 +41,12 @@ export default function EventTimeChanger({
5241} : EventTimeChangerProps ) {
5342 const { t } = useTranslation ( [ COMMUNITIES ] ) ;
5443
44+ // FIXME(#8064): Event times should be interpreted in their timezones.
5545 const defaultStartDateTime = event ?. startTime
56- ? toPlainDateTime ( event . startTime )
46+ ? timestampToPlainDateTime ( event . startTime )
5747 : undefined ;
5848 const defaultEndDateTime = event ?. endTime
59- ? toPlainDateTime ( event . endTime )
49+ ? timestampToPlainDateTime ( event . endTime )
6050 : undefined ;
6151
6252 const handleStartDateChange = ( value : Temporal . PlainDate ) => {
0 commit comments