Skip to content

Commit

Permalink
🐛 Adjust month logic #2791 (#2813)
Browse files Browse the repository at this point in the history
  • Loading branch information
millianapia authored Feb 6, 2025
1 parent f2028e0 commit be97c27
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions web/common/helpers/dateUtilities.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getYear, getMonth, getDate, getHours, getMinutes, getSeconds } from 'date-fns'
import { zonedTimeToUtc } from 'date-fns-tz'
import { EventDateType } from '../../../web/types/index'
import { zonedTimeToUtc } from 'date-fns-tz'

export const toDateParts = (datetime: Date): number[] => {
return [
getYear(datetime),
getMonth(datetime),
getMonth(datetime) + 1,
getDate(datetime),
getHours(datetime),
getMinutes(datetime),
Expand All @@ -16,7 +16,7 @@ export const toDateParts = (datetime: Date): number[] => {
export const toUTCDateParts = (datetime: Date): number[] => {
return [
datetime.getUTCFullYear(),
datetime.getUTCMonth(),
datetime.getUTCMonth() + 1,
datetime.getUTCDate(),
datetime.getUTCHours(),
datetime.getUTCMinutes(),
Expand All @@ -27,11 +27,9 @@ export const toUTCDateParts = (datetime: Date): number[] => {
export const getEventDates = (eventDate: EventDateType | undefined) => {
if (!eventDate) {
console.warn('Missing eventDate object for event')
// This is indeed not optimal
return { start: null, end: null }
}
const { date, startTime, endTime, timezone } = eventDate

if (!date) return { start: null, end: null }

const universalDate = date.replace(/-/g, '/')
Expand Down

0 comments on commit be97c27

Please sign in to comment.