fix(date): change only in device to UTC
This commit is contained in:
@@ -208,8 +208,8 @@ const DetailDevice = (props) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (formData.start_date && formData.end_date) {
|
if (formData.start_date && formData.end_date) {
|
||||||
const start = dayjs(formData.start_date);
|
const start = dayjs.utc(formData.start_date);
|
||||||
const end = dayjs(formData.end_date);
|
const end = dayjs.utc(formData.end_date);
|
||||||
|
|
||||||
let periodValue = 'custom';
|
let periodValue = 'custom';
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ const DetailDevice = (props) => {
|
|||||||
if (value !== 'custom') {
|
if (value !== 'custom') {
|
||||||
const months = Number(value);
|
const months = Number(value);
|
||||||
|
|
||||||
const startDate = dayjs().startOf('day');
|
const startDate = dayjs.utc().startOf('day');
|
||||||
const endDate = startDate
|
const endDate = startDate
|
||||||
.add(months, 'month')
|
.add(months, 'month')
|
||||||
.subtract(1, 'day')
|
.subtract(1, 'day')
|
||||||
@@ -470,7 +470,7 @@ const DetailDevice = (props) => {
|
|||||||
<DatePicker
|
<DatePicker
|
||||||
value={
|
value={
|
||||||
formData.reminder_at
|
formData.reminder_at
|
||||||
? dayjs(formData.reminder_at) // ✅ langsung parse ISO
|
? dayjs.utc(formData.reminder_at) // ✅ langsung parse ISO
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
onChange={(date) =>
|
onChange={(date) =>
|
||||||
@@ -517,14 +517,14 @@ const DetailDevice = (props) => {
|
|||||||
<div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
|
<div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
placeholder="Start Date"
|
placeholder="Start Date"
|
||||||
value={formData.start_date ? dayjs(formData.start_date) : null}
|
value={formData.start_date ? dayjs.utc(formData.start_date) : null}
|
||||||
onChange={(date) =>
|
onChange={(date) =>
|
||||||
handleDateChange('start_date', date ? date.toISOString() : null)
|
handleDateChange('start_date', date ? date.toISOString() : null)
|
||||||
}
|
}
|
||||||
disabledDate={(current) =>
|
disabledDate={(current) =>
|
||||||
formData.end_date &&
|
formData.end_date &&
|
||||||
current &&
|
current &&
|
||||||
current.isAfter(dayjs(formData.end_date), 'day')
|
current.isAfter(dayjs.utc(formData.end_date), 'day')
|
||||||
}
|
}
|
||||||
format="DD-MM-YYYY HH:mm"
|
format="DD-MM-YYYY HH:mm"
|
||||||
showTime={{ format: 'HH:mm' }}
|
showTime={{ format: 'HH:mm' }}
|
||||||
@@ -533,14 +533,14 @@ const DetailDevice = (props) => {
|
|||||||
|
|
||||||
<DatePicker
|
<DatePicker
|
||||||
placeholder="End Date"
|
placeholder="End Date"
|
||||||
value={formData.end_date ? dayjs(formData.end_date) : null}
|
value={formData.end_date ? dayjs.utc(formData.end_date) : null}
|
||||||
onChange={(date) =>
|
onChange={(date) =>
|
||||||
handleDateChange('end_date', date ? date.toISOString() : null)
|
handleDateChange('end_date', date ? date.toISOString() : null)
|
||||||
}
|
}
|
||||||
disabledDate={(current) =>
|
disabledDate={(current) =>
|
||||||
formData.start_date &&
|
formData.start_date &&
|
||||||
current &&
|
current &&
|
||||||
current.isBefore(dayjs(formData.start_date), 'day')
|
current.isBefore(dayjs.utc(formData.start_date), 'day')
|
||||||
}
|
}
|
||||||
format="DD-MM-YYYY HH:mm"
|
format="DD-MM-YYYY HH:mm"
|
||||||
showTime={{ format: 'HH:mm' }}
|
showTime={{ format: 'HH:mm' }}
|
||||||
@@ -555,7 +555,7 @@ const DetailDevice = (props) => {
|
|||||||
disabled={formData.period === 'custom'}
|
disabled={formData.period === 'custom'}
|
||||||
value={
|
value={
|
||||||
formData.reminder_at_monthly
|
formData.reminder_at_monthly
|
||||||
? dayjs(formData.reminder_at_monthly) // ✅ langsung parse ISO
|
? dayjs.utc(formData.reminder_at_monthly) // ✅ langsung parse ISO
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
onChange={(date) =>
|
onChange={(date) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user