-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Calendar issue UTC - beta19 #1113
Comments
I still have the same issue beta20. Is it only me that is facing this? |
Yep .. I think I'm having the same thing on beta20. I've some other issues with timezone that seems to be causing the value to be different in IE vs Chrome .. not sure if that's related yet, need to investigate it |
Hi, I suffer the same problem.
Consider choosing a date from the calendar (without time) set the date in 00:00:00 in UTC time but not 00:00:00 in local time zone. Selecting a date from browser in Germany should set 2016-11-04T00:01:00+01:00, in Bulgaria - 2016-11-04T00:02:00+02:00, etc... So this line: may become
|
Yes, it would be great if there will be a timezone property to get the UTC date where the default is local timezone. Something like: |
Default local timezone and utc boolean attribute as proposed by @mrgoos sounds great. |
I'm having this same issue with 1.0.0 and it's critical as it creates a date mismatch between what the user selects and what is stored to my database (which must store the dates in UTC). Have there been any updates or have any of the solutions proposed above been considered? |
@rfboykin - as a workaround you can use this to get UTC date by sending calendar's date to this function: getUTCDate(date: Date): Number {
return date.getTime() / 1000 - date.getTimezoneOffset() * 60;
} |
I also came across this issue today and editing calendar.js file as @ilianiv proposed fixed the problem for me. Are there any plans on making these changes in the new version? |
ref @ilianiv comment on 4 Nov 2016 the line does not appear to have been fixed in subsequent pull requests if you are using primeng "1.0.0-rc.1") (and do not have the ts source) you can edit node_modules/primeng/components/calendar/calendar.js instead: around line 207 |
This issue is still not fixed in 2.0.1 - are there any plans to fix it anytime soon? |
Calendar date format as UTC - Fix #1113
BUG REPORT: Current behaviour: Selecting: Expected behaviour: Selecting: Testable on your example site: https://www.primefaces.org/primeng/#/calendar Date selected should not be converted to UTC since it changes the actual date and time selected by the user. If you want to give date/time in UTC as a boolean flag option, then truncate the timezone instead of converting to UTC and changing the selected date/time. Example: "18:00:00 GMT-0400" becomes "18:00:00 GMT-0000". |
+1 I couldn't upgrade my app because of this issue, I'm using calendar in many components. Sometimes I need the UTC time, but most of the time I need the local user time and with this change I would have to add a lot of boilerplate code to get the local time. The @mrgoos idea to add an attribute like "utc"=true sounds good. |
Reverting due to regressions; 2426 |
Adding |
I am using for past experience, where it does not need time. |
I fixed the issue by extending the Calendar class, then hid/rewrote the base class updateModel function, copy/paste its base functionality and added this line this.fixUTCDate(this.value); in the beginning of the function . private fixUTCDate(date): void { Works with both selecting the date and typing it manually. |
I have a very strange issue with the new Calendar module:
Example:
This is the result (the initial value is not set, but i think this is a known issue at the moment):
This is what happens when you select a date:
Basically the bound value is incorrect after the conversion to JSON string (it represents the day before) due to the timezone. But there is no other way to submit the value back to the API.
Is there a way for this component to work (internally) in UTC? Maybe somehow using
dateObj.getTimezoneOffset()
to compensate for the time zone difference?This is the offending code:
components/calendar/calendar.ts:417
-this.value = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
Edit: added comments
The text was updated successfully, but these errors were encountered: