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

Ios Event Date Time wrong and confused #417

Open
LuisBonsembiante opened this issue Sep 8, 2022 · 1 comment
Open

Ios Event Date Time wrong and confused #417

LuisBonsembiante opened this issue Sep 8, 2022 · 1 comment

Comments

@LuisBonsembiante
Copy link

LuisBonsembiante commented Sep 8, 2022

I have an iOS device with CDT(GMT-5) timezone. An I created a date with time in 13:00 and with EDT(GMT-4) timezone. Expected hour in calendar: 12AM. Obtained:

image

Environment

React Native 0.64.2
react-native-calendar-events: 2.2.0

Steps to Reproduce

const dateStr = date.format('YYYY-MM-DD HH:mm:ss');
  const localOffset = moment().utcOffset() / 60;

  const offset = addLeadingZeros(timeZoneCalendar, 2);
  const offsetLocal = addLeadingZeros(localOffset, 2);
  const momentDate = moment(dateStr, 'YYYY-MM-DD HH:mm:ss').utcOffset(
    offset,
    true
  );

  const utcDate = momentDate.utc().format('YYYY-MM-DD HH:mm:ss');
  const dateWithFinalUTC =    
       moment(utcDate, 'YYYY-MM-DDTHH:mm:ss.SSS[Z]')
          .add(offsetLocal, 'h')
          .format('YYYY-MM-DDTHH:mm:ss.SSSZ');

Expected Behavior

Like android behavior, set the ISO string with correct time.

Actual Behavior

Wrong date, this sceneries not happen in Android

@LuisBonsembiante LuisBonsembiante changed the title Ios Event Date Time wrong and condused Ios Event Date Time wrong and confused Sep 8, 2022
@Udbhav9628
Copy link

Do it like this

change it according to your need
`const Match_time = (new Date(Item.Date_Time).getTime() - 1200000);
const Match_Time_Before_20_Min = new Date(Match_time);

  const TimeAfter_1_Hr = (new Date(Item.Date_Time).getTime() + 2400000);
  const TimeDate_After_40_Min = new Date(TimeAfter_1_Hr);

  await RNCalendarEvents.saveEvent(`Your ${Item.Game_Name} Match is about to start in 15 Minutes`, {
    startDate: Match_Time_Before_20_Min.toISOString(),
    endDate: TimeDate_After_40_Min.toISOString(),
  })`

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