date.js解析方法覆盖Javascript Parse方法 [英] date.js Parse method overrides Javascript Parse method

查看:140
本文介绍了date.js解析方法覆盖Javascript Parse方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站中包含 date.js 库,因为我需要它的功能。



尽管如此,我已经意识到标准的Javascript parse()方法被它覆盖。



我试图在Highcharts中构建一个折线图,数据系列希望第一个元素以毫秒为单位(他们的演示使用 Date.UTC()方法来实现这一点,但我的数据以不同的格式返回)。



没有做一堆字符串操作来将我的数据放入 Date.UTC 的格式,是否有另一种获取标准Javascript parse()功能的方法,而 date.js 加载?

解决方案

我知道这不是解决您的问题的直接解决方案,但可能有帮助。



如果您想要一个功能完整的日期库,它不会修改本地 Date 对象,我写了一个名为Moment.js。



它提供了许多DateJS提供的功能(格式化,解析,操作,时间,i18n等),但它更小,更快,并且不会破坏本机日期原型。 / p>

https://github.com/timrwood/moment


I'm including the date.js library in my site because I need its functionality.

I have just realized, though, that the standard Javascript parse() method is overwritten by it.

I'm trying to build a line chart in Highcharts, and the data series wants the first element to be be in milliseconds (their demos show them using the Date.UTC() method to achieve this, but my data is returned in a different format).

Short of doing a bunch of string manipulation to put my data into a format that Date.UTC will recognize, is there another way of getting the standard Javascript parse() functionality while date.js is loaded?

解决方案

I know this isn't a direct solution to your problem, but it may help anyway.

If you want a fully featured date library that doesn't modify the native Date object, I wrote one called Moment.js.

It provides a lot of the things that DateJS provides (formatting, parsing, manipulation, timeago, i18n, etc), but it's smaller, faster, and doesn't ruin the native date prototype.

https://github.com/timrwood/moment

这篇关于date.js解析方法覆盖Javascript Parse方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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