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

Having issues setting up UTC 0 Timezone with PrimeReact Calendar. #5513

Closed
FurkanCodes opened this issue Dec 4, 2023 · 1 comment
Closed
Labels
Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted

Comments

@FurkanCodes
Copy link

FurkanCodes commented Dec 4, 2023

In my application, I have a calendar component that dispatches start and end dates. However, the time conversion is not working as I wanted it to.
It sends in GMT+3 which is absolutely fine, so I wrote a small UTC Conversion method but due to reasons that I cannot quite understand it does not convert the time properly. It works for Material UI's calendar. Why would this be happening? Does PrimeReact handle calendar output different than MUI for example?

This is how I am converting the time

UTCDate = (utcDate: Date) => {
        const _utcDate = new Date(utcDate.toISOString());
        const gmtOffset = _utcDate.getTimezoneOffset();
        const hours = Math.floor(gmtOffset / 60);
        _utcDate.setHours(_utcDate.getHours() - hours, _utcDate.getMinutes(), 0, 0);
        return _utcDate;
    };
    
    <Calendar showTime name="startDate" onChange={(date) => handleDate(date, "startDate")}></Calendar>
      <Calendar showTime name="endDate"   onChange={(date) => handleDate(date, "endDate")}></Calendar>
                       

and This is my function;

       const handleDate = (date, field) => {
        const a = helperMethods.UTCDate(date);
        console.log(a);
// I am dispatching to my redux store
         dispatch(setStuff({ ...createApplicationRequestModel, [field]: a }));
    };

So far this returns;

utcDate.toISOString is not a function, then I try converting the value from Calendar to new Date, the error disappears but then my intended functionality still does not work.

Any guidance or help is appreciated, I would like to stick to PrimeReact's calendar if possible

@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 4, 2023
@melloware
Copy link
Member

Duplicate of #4128

@melloware melloware marked this as a duplicate of #4128 Dec 4, 2023
@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
@melloware melloware added Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted
Projects
None yet
Development

No branches or pull requests

2 participants