Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in month view, dates that time is exactly 00:00:00 are not displayed on the calendar cell #1134

Open
relay955 opened this issue Feb 4, 2025 · 3 comments

Comments

@relay955
Copy link

relay955 commented Feb 4, 2025

this is easily reproduce on android simulator API 34, It is set to UTC+0:00.

Is this exactly intended?

I am currently using the code below.

CalendarBodyForMonthView.tsx, 140

        let filteredEvents = events
          .filter(
            ({ start, end }) =>
              dayjs(end).isSameOrAfter(day.startOf('week')) && dayjs(start).isSameOrBefore(max),
          )

and add extention isSameOrAfter, isSameOrBefore in index.ts

import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'

dayjs.extend(isSameOrAfter)
dayjs.extend(isSameOrBefore)
@relay955 relay955 changed the title in month view, dates that time is exactly 00:00:00 are not displayed on the calendar cell. in month view, dates that time is exactly 00:00:00 are not displayed on the calendar cell Feb 4, 2025
@acro5piano
Copy link
Owner

Can you provide reproductive code? Storybook is also helpful.

I suspect they are treated as a all-day event

@relay955
Copy link
Author

thanks for your intrest, here is my storybook reproducible sample.

import { storiesOf } from '@storybook/react'
import React, { useCallback } from 'react'
import { Button } from 'react-native'

import { Calendar } from '../src'
import dayjs from "dayjs";

const MOBILE_HEIGHT = 736

storiesOf('reproduction-issue-1134', module)
  .add('month mode', () => <CalendarContainer swipeEnabled={true} />)

interface CalendarContainerProps {
  swipeEnabled: boolean
}

const events = [
  {
    title: 'event1',
    start: dayjs("2025-02-09").toDate(),
    end: dayjs("2025-02-15").toDate(),
  },
  {
    title: 'event2',
    start: dayjs("2025-02-09").toDate(),
    end: dayjs("2025-02-16").toDate(),
  },
  {
    title: 'event3',
    start: dayjs("2025-02-09").toDate(),
    end: dayjs("2025-02-17").toDate(),
  },
  {
    title: 'event4',
    start: dayjs("2025-02-16").toDate(),
    end: dayjs("2025-02-16").toDate(),
  },
]

const CalendarContainer: React.FC<CalendarContainerProps> = ({ swipeEnabled }) => {
  return (
    <>
      <Calendar
        events={events}
        swipeEnabled={swipeEnabled}
        date={new Date("2025-02-01")}
        height={MOBILE_HEIGHT}
        mode="month"
      />
    </>
  )
}

result
Image
event 4, event 2 did not render correctly.

I've confirmed that this only happens at the beginning of the week. In the example below, multiple days events that end at the start of the week or are set at the start of a specific week are not showing up.

For now, I'm using a temporary fix with the code below.

        let filteredEvents = events
          .filter(
            ({ start, end }) =>
            (dayjs(end).isSame(day.startOf('week')) || dayjs(end).isAfter(day.startOf('week'))) && dayjs(start).isBefore(max),
          )

@acro5piano
Copy link
Owner

@relay955 I'm sorry, but can you provide the storybook with the new format? It was updated last week. If possible a PR is welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants