kkaefer / chrono.js Goto Github PK
View Code? Open in Web Editor NEWFormat dates in JavaScript
License: MIT License
Format dates in JavaScript
License: MIT License
The second assertion here fails:
assert.eql(new Date('Feb 28 2004').interval(new Date('Feb 28 2005')), ['1 year']);
assert.eql(new Date('Feb 28 2004').interval(new Date('Mar 1 2005')), ['1 year', '1 day']);
Not sure how you'd like to go about this:
Set system timezone to GMT +08:00 (for example) and test fail with the following:
chrono.test.js test missing timezone parameter: AssertionError: "NaN" == 3
at Test.exports.test missing timezone parameter [as fn] (/Users/willwhite/chrono.js/test/chrono.test.js:62:10)
at Test.runParallel (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:959:10)
at Test.run (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:924:18)
at next (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:867:22)
at Test.run (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:925:13)
at next (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:867:22)
at Test.run (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:925:13)
at next (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:867:22)
at Test.run (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:925:13)
at next (/Users/willwhite/.nvm/v0.8.18/lib/node_modules/expresso/bin/expresso:867:22)
Failures: 1
make: *** [test] Error 1
console.warn(new Date('Jan 30 2012').getUTCDaysOfMonth());
// 29
console.warn(new Date('Jan 30 2012').interval(new Date('Feb 6, 2012')));
// 5
If the system time is set to some timezones (examples: ALMT (Kazakhstan), CST (China)), time interval tests fail.
$ make test
chrono.test.js test time intervals: AssertionError: ["1 year","1 day"] deepEqual ["1 year","2 days"]
at Test.exports.test time intervals [as fn] (/Users/chris/mapbox/chrono.js/test/chrono.test.js:149:12)
at Test.runParallel (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:959:10)
at Test.run (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:924:18)
at next (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:867:22)
at Test.run (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:925:13)
at next (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:867:22)
at Test.run (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:925:13)
at next (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:867:22)
at Test.run (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:925:13)
at next (/Users/chris/.nvm/v0.8.26/lib/node_modules/expresso/bin/expresso:867:22)
Failures: 1
make: *** [test] Error 1
Looks like v1.0.5 was published but no git tag is visible.
We cool for a new tag/release? I can take care of this if you think things are stable.
The following description is stolen from: http://cr.yp.to/libtai/tai64.html
A TAI64 label is an integer between 0 and 2^64 referring to a
particular second of real time. Integer s refers to
Integers 2^63 and larger are reserved for future extensions. Under many
cosmological theories, the integers under 2^63 are adequate to cover
the entire expected lifetime of the universe; in this case no extensions
will be necessary.
A TAI64 label is normally stored or communicated in external TAI64
format, consisting of eight 8-bit bytes in big-endian format. This
means that bytes b0 b1 b2 b3 b4 b5 b6 b7 represent the label b0 * 2^56
For example, bytes 3f ff ff ff ff ff ff ff hexadecimal represent the
second that ended 1969 TAI; bytes 40 00 00 00 00 00 00 00 hexadecimal
represent the second that began 1970 TAI; bytes 40 00 00 00 00 00 00 01
hexadecimal represent the following second. Bytes 40 00 00 00 2a 2b 2c
2d hexadecimal represent 1992-06-02 08:07:09 TAI, also known as
1992-06-02 08:06:43 UTC.
A TAI64N label refers to a particular nanosecond of real time. It has
two parts:
A TAI64N label is normally stored or communicated in external TAI64N
format, consisting of twelve 8-bit bytes. The first eight bytes are the
TAI64 label in external TAI64 format. The last four bytes are
the nanosecond counter in big-endian format.
A TAI64NA label refers to a particular attosecond of real time. It has
two parts:
A TAI64NA label is normally stored or communicated in external TAI64NA
format, consisting of sixteen 8-bit bytes. The first twelve bytes are
the TAI64N label in external TAI64N format. The last four
bytes are the attosecond counter in big-endian format.
Many network protocols and filesystems store timestamps in the original
UNIX format: a signed 32-bit integer representing the number of seconds
since the beginning of 1970. This format will expire in 2038. Other
protocols store timestamps as unsigned 32-bit integers representing the
number of seconds since 1900; this format will expire in 2036.
TAI64 was defined in July 1997 for use in new protocols. TAI64N and
TAI64NA were defined at the same time for protocols where 1-second
precision is insufficient.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.