fix: account for am/pm
This commit is contained in:
parent
3316e17dff
commit
aed45ed1bb
1 changed files with 7 additions and 2 deletions
|
@ -106,11 +106,16 @@ export default async () => {
|
||||||
const endTime = new Date(endDate).toLocaleString('en-US', {
|
const endTime = new Date(endDate).toLocaleString('en-US', {
|
||||||
timeZone: 'America/Los_Angeles',
|
timeZone: 'America/Los_Angeles',
|
||||||
})
|
})
|
||||||
const now = new Date().toLocaleString('en-US', {
|
const nowDate = new Date()
|
||||||
|
const now = nowDate.toLocaleString('en-US', {
|
||||||
timeZone: 'America/Los_Angeles',
|
timeZone: 'America/Los_Angeles',
|
||||||
})
|
})
|
||||||
|
const startAmPm = startDate.getHours() >= 12 ? 'pm' : 'am'
|
||||||
|
const nowAmPm = nowDate.getHours() >= 12 ? 'pm' : 'am'
|
||||||
const isCorrectDate =
|
const isCorrectDate =
|
||||||
now.split(',')[0] === startTime.split(',')[0] && now.split(',')[0] === endTime.split(',')[0]
|
now.split(',')[0] === startTime.split(',')[0] &&
|
||||||
|
now.split(',')[0] === endTime.split(',')[0] &&
|
||||||
|
startAmPm === nowAmPm
|
||||||
const nowHour = parseInt(now.split(',')[1].split(':')[0].trim())
|
const nowHour = parseInt(now.split(',')[1].split(':')[0].trim())
|
||||||
const startHour = parseInt(startTime.split(',')[1].split(':')[0].trim())
|
const startHour = parseInt(startTime.split(',')[1].split(':')[0].trim())
|
||||||
const endHour = parseInt(endTime.split(',')[1].split(':')[0].trim())
|
const endHour = parseInt(endTime.split(',')[1].split(':')[0].trim())
|
||||||
|
|
Reference in a new issue