Code Monkey home page Code Monkey logo

chrono.js's People

Contributors

chrisforbes avatar kkaefer avatar taketime avatar wildintellect avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chrono.js's Issues

Leap year intervals

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:

  • The first result of interval() is actually not correct if you take a year to be 365 days. There are 366 days between Feb 28 04 and Feb 28 05.
  • The second result of interval() is actually correct (it yields 1 year, 2 days) which is what I'd expect but the test looks for one day less.

Tests fail with NaN when run in GMT +08:00, possibly others

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

UR CODE DOESNT WORK IN AMERICA

console.warn(new Date('Jan 30 2012').getUTCDaysOfMonth());
// 29
console.warn(new Date('Jan 30 2012').interval(new Date('Feb 6, 2012')));
// 5

Time interval tests fail when in some timezone

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

push git tag

Looks like v1.0.5 was published but no git tag is visible.

Release?

We cool for a new tag/release? I can take care of this if you think things are stable.

Please support TAI64, TAI64N, and TAI64NA

The following description is stolen from: http://cr.yp.to/libtai/tai64.html

TAI64 labels and external TAI64 format

A TAI64 label is an integer between 0 and 2^64 referring to a
particular second of real time. Integer s refers to

  • the TAI second beginning exactly 2^62 - s seconds before the
    beginning of 1970 TAI, if s is between 0 inclusive and 2^62
    exclusive; or
  • the TAI second beginning exactly s - 2^62 seconds after the
    beginning of 1970 TAI, if s is between 2^62 inclusive and 2^63
    exclusive.

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

  • b1 * 2^48 + b2 * 2^40 + b3 * 2^32 + b4 * 2^24 + b5 * 2^16 +
    b6 * 2^8 + b7.

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.

TAI64N labels and external TAI64N format

A TAI64N label refers to a particular nanosecond of real time. It has
two parts:

  1. a TAI64 label and
  2. an integer, between 0 and 999999999 inclusive, counting nanoseconds
    from the beginning of the second represented by the TAI64 label.

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.

TAI64NA labels and external TAI64NA format

A TAI64NA label refers to a particular attosecond of real time. It has
two parts:

  1. a TAI64N label and
  2. an integer, between 0 and 999999999 inclusive, counting attoseconds
    from the beginning of the nanosecond represented by the TAI64N
    label.

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.

Historical notes

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.