GithubHelp home page GithubHelp logo

Date.date about edtf.js HOT 4 CLOSED

retorquere avatar retorquere commented on June 21, 2024
Date.date

from edtf.js.

Comments (4)

inukshuk avatar inukshuk commented on June 21, 2024 1

Regarding the first example: we are always converting to UTC, because otherwise a number of important calculations would become insanely difficult or simply impossible. The date is still correct, so you can calculate it according to your desired timezone. If you are just interested in the string representation (i.e., get 18 out) then don't use the date library, just parse the string:

e.parse('2016-07-18T20:26:06+10:00').values[2]
// -> 18

Similarly for the second example, don't use the date library if you just want to parse the numbers:

e.parse('-0876').values[2]
// -> undefined

The point of the date library is to manipulate dates and convert them back to EDTF strings. For that reason, we're using the concept that every extended date covers a period of time with a min/max value. This approach is necessary to do computations, that's why the day exists, even though the date has year precision (you can still query the precision and convert the date back to a string and you will see that there is no day set, but because it is required for computations you can still get an approximation if you need it).

from edtf.js.

inukshuk avatar inukshuk commented on June 21, 2024 1

Yes, you can either use the extended date objects directly, or, alternatively, use the Bitmask class (unspecified and uncertain are simply Bitmask instances created from the numeric value returned by the parser).

from edtf.js.

retorquere avatar retorquere commented on June 21, 2024

Please do let me know if this is not the proper channel... if I parse 1999-XX-XX I get (as expected) { values: [ 1999, 0, 1 ], unspecified: 240, type: 'Date', level: 1 }, but .unspecified.is(...) clearly won't work here. How do I call Bitmask directly to find out what part is unspecified?

from edtf.js.

retorquere avatar retorquere commented on June 21, 2024

Or could I just use edtf('...').values and edtf('...').unspecified.is(...)?

from edtf.js.

Related Issues (20)

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.