[英]Date Picker for Angular that Ignores Local Timezone
Is there any date picker that just displays what is supplied to it and ignores the local timezone? 是否有任何日期选择器只显示提供给它的内容并忽略当地时区?
We're currently using angular-strap
's date picker and the data-min-date
changes when the local time zone of the computer is changed. 我们目前正在使用
angular-strap
的日期选择器,并且当计算机的本地时区发生变化时, data-min-date
发生变化。 The supplied data-min-date
is just a fixed date but somehow the date picker is affected by the local time zone. 提供的
data-min-date
只是一个固定的日期,但不知何故日期选择器受当地时区的影响。
Example: 例:
Supplied Date: 2016-12-23T16:33:03+08:00
ISO8601 Format
提供日期:
2016-12-23T16:33:03+08:00
ISO8601 Format
On UTC-12:00
22-December-2016
is disabled so the minimum is 23-December-2016
. 在
UTC-12:00
22-December-2016
被禁用,因此最低要求是23-December-2016
。
On UTC+08:00
23-December-2016
is disabled so the minimum is 24-December-2016
. 在
UTC+08:00
23-December-2016
停用,所以最低要求是24-December-2016
。
Not sure which one is the expected date, but the expected outcome should be that there will be no changes since a fixed date is supplied. 不确定哪一个是预期日期,但预期结果应该是自提供固定日期以来不会有任何变化。
Is there anything I am missing or any other calendar that will just display what is given to it? 我有什么遗漏或任何其他日历只会显示给它的东西吗?
EDIT 1 : Is it a legit way to test date functionalities by changing the local timezone of a computer? 编辑1 :通过更改计算机的本地时区来测试日期功能是否合法? Is it the same or different than when you are locally or naturally situated in that timezone?
它是否与您在当地或自然位于该时区的情况相同或不同?
EDIT 2 : We already generated datetime from our node server
using momentjs
. 编辑2 :我们已经使用
momentjs
从我们的node server
生成了日期momentjs
。 var serverTime = moment().utcOffset(8);
it's just the the angular-strap
handles the date we supplied in an odd way. 只是
angular-strap
以奇怪的方式处理我们提供的日期。
EDIT 3 : Adding an attribute data-timezone="utc"
doesn't help either. 编辑3 :添加属性
data-timezone="utc"
也无济于事。
EDIT 4 : We've discovered that the plug-in uses date = new Date(value);
编辑4 :我们发现插件使用
date = new Date(value);
in which value
is the date that we passed. 其中
value
是我们通过的日期。 And it returns something like Thu Dec 22 2016 21:29:54 GMT-1200 (Local Standard Time)
which clearly uses the local timezone. 它会返回类似于
Thu Dec 22 2016 21:29:54 GMT-1200 (Local Standard Time)
,它显然使用当地时区。 And there is no condition to check if there is timezone="utc"
supplied. 并且没有条件检查是否提供了
timezone="utc"
。 We also tried to directly assign date = Thu Dec 22 2016 21:29:54 GMT-1200 (Local Standard Time)
but the plug-in breaks. 我们还尝试直接指定
date = Thu Dec 22 2016 21:29:54 GMT-1200 (Local Standard Time)
但插件中断。
We did a hack around. 我们做了一个黑客。 We forked the plug in and changed the code that handles the
min-date
. 我们分叉插件并更改了处理
min-date
的代码。
Change history can be found here . 可以在此处找到更改历史记录。 Snippet we added:
我们添加的代码片段:
var a = new Date(value); // value - date we are passing
var b = a.getTime() + (a.getTimezoneOffset() * 60000); // no idea what this is
date = new Date(b + (3600000*(8))); // the 8 is the timezone we want
The problem with the new Date(value)
is that it is affected by the local timezone. new Date(value)
的问题在于它受本地时区的影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.