您可以创建低于公元前 271800 年的日期吗?像恐龙时代? [英] Can you create dates that are lower than 271800 BC? Like dinosaur time?

查看:13
本文介绍了您可以创建低于公元前 271800 年的日期吗?像恐龙时代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我对 javascript 日期的看法:

This is as low as I can seem to go with javascript date:

var myDate = new Date(0, 0, 1);
myDate.setFullYear("-271800");
alert(myDate);

任何低于 -271,800 BC 的值都会引发无效的日期错误.我们能回到一百万年前吗?还是十亿?日期对象可以让你无限地描述过去或未来的任何日期吗?我该怎么做?

Anything lower than -271,800 BC throws an invalid date error. Can we go back a million years? Or a billion? Can the date object allow you to describe any date infinitely in the past or future? How might I do something like this?

推荐答案

表示一百万年前的特定日期在我看来毫无意义.儒略历?一周中的几天应该遵守巴比伦系统吗?

Representing a particular date a million years ago strikes me as meaningless. Julian calendar? Should days of week honor the Babylonian system?

为此创建您自己的类型,确定您实际需要表示的内容.

Create your own type for this, decide what you actually need to represent.

--- 更新:这已被接受,因此我将添加一些更具体的位.---

--- Updated: This was accepted, so I'll add a few more specific bits. ---

如另一个答案中所述,根据 EcmaScript 规范,第 164 页第五版(链接是.pdf.)

As mentioned in another answer, according to the EcmaScript spec, pg 164 of the fifth edition (link is a .pdf.)

时间在 ECMAScript 中以毫秒为单位测量,自 1970 年 1 月 1 日起世界标准时间.在时间值中,闰秒被忽略.假设每天正好有 86,400,000 毫秒.ECMAScript 编号值可以表示从 –9,007,199,254,740,991 到的所有整数9,007,199,254,740,991;这个范围足以测量时间任何瞬间的毫秒精度,大约在自 UTC 时间 1970 年 1 月 1 日起向前或向后 285,616 年.

Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. In time values leap seconds are ignored. It is assumed that there are exactly 86,400,000 milliseconds per day. ECMAScript Number values can represent all integers from –9,007,199,254,740,991 to 9,007,199,254,740,991; this range suffices to measure times to millisecond precision for any instant that is within approximately 285,616 years, either forward or backward, from 01 January, 1970 UTC.

ECMAScript Date 对象支持的实际时间范围是略小:正好 –100,000,000 天到 100,000,000 天相对于 1970 年 1 月 1 日开始的午夜测量世界标准时间.这给出了 8,640,000,000,000,000 毫秒到UTC 时间 1970 年 1 月 1 日的任一侧.

The actual range of times supported by ECMAScript Date objects is slightly smaller: exactly –100,000,000 days to 100,000,000 days measured relative to midnight at the beginning of 01 January, 1970 UTC. This gives a range of 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC.

但是,这是理论日期.它忽略了一些现实.一百万年前,天变短了(减少了 12 秒),所以一些 JavaScript 数学计算是不准确的.星期几已用不同的系统确定.月份的定义不同.总而言之,决定你真正需要代表什么.

But, this is for theoretical dates. It ignores a few pieces of reality. Days were shorter (by 12 seconds) a million years ago, so some JavaScript math would be inaccurate. Days of the week have been determined with different systems. Months have been defined differently. All to say, decide what you really need to represent.

这篇关于您可以创建低于公元前 271800 年的日期吗?像恐龙时代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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