剑道DateTimePicker不处理UTC偏移 [英] Kendo DateTimePicker Not Handling UTC Offset

查看:82
本文介绍了剑道DateTimePicker不处理UTC偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用通过AngularJS指令实现的Kendo datetimepicker:

We are using the Kendo datetimepicker, implemented using the AngularJS directives:

<input type="text" kendo-date-time-picker k-ng-model="TheDateModel">

其中:TheDateModel = 2016-02-15 20:58:24.0000000 +00:00

Where: TheDateModel = 2016-02-15 20:58:24.0000000 +00:00

我处于CST时区,与格林尼治标准时间-6时偏移.datetimepicker的当前结果显示时间为8:58 pm,但我的预期结果是2:58 pm.

I am in the CST timezone, which is -6 hour offset from the GMT. The current result of the datetimepicker shows a time of 8:58 pm but my expected result is 2:58 pm.

我到底在做错什么?

推荐答案

免责声明:我为Kendo UI团队工作

Disclaimer: I work for Kendo UI team

Kendo UI Datepicker内部使用JavaScript Date对象保存选定​​的日期值.您可能知道,它始终使用本地(浏览器)时区.我们也试图在我们的文档中解释这一警告:

The Kendo UI Datepicker uses JavaScript Date object internally to hold the selected date value. As you probably know, it always uses the local (browser) timezone. We tried to explain that caveat in our docs too:

由于此默认行为,窗口小部件将使用已转换的Date值(带有应用的本地时区).该小部件无法操纵值时区,因为它没有足够的信息来做到这一点.

Due to this default behavior, the widget will use the already converted Date value (with the applied local timezone). The widget doesn't manipulate the value timezone, as it does not have sufficient information how to do that.

解决方案

在这种情况下,最好的方法是在输入DatePicker小部件之前手动转换Date字符串(如您提到的"2016-02-15 20:58:24.0000000 +00:00").例如,这是一种可行的方法:

The best approach in this case is to convert the Date strings (like the one you mentioned "2016-02-15 20:58:24.0000000 +00:00") manually before feed the DatePicker widget. For instance, here is one possible approach to do that:

注意如何在 loadData 方法中解析然后调整值.需要在其应用程序中处理不同的TZ的开发人员应执行类似的操作.

Notice how the value is parsed and then adjusted in the loadData method. Similar thing should be done by the developer that needs to handle different TZ in their app.

这篇关于剑道DateTimePicker不处理UTC偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆