Giter Club home page Giter Club logo

Comments (3)

coolaj86 avatar coolaj86 commented on August 19, 2024

Can you give some more concrete examples?

from tz.js.

ryanburnette avatar ryanburnette commented on August 19, 2024

Sure.

My thought is that while the resulting object is somewhat unique to this library, the attributes of the object could follow Unicode date patterns used by most other libraries one would encounter when dealing with dates.

I usually use date-fns, for example, and would format a date object like this.

formatDate(new Date(), 'MM dd, YYYY');

If your library generated an object with attributes that adhered to Unicode date patterns, you could do the same thing. Example:

// fake object with a few example attributes
var obj = {
  MM: 'March',
  dd: '3',
  YYYY: '2022'
};

var formattedDate = `${obj.MM} ${obj.dd}, ${obj.YYYY}`;

Having the ability to turn a date into an object like this is much more convenient than including date-fns and I'd use such a library all the time.

I must add a disclaimer that my understanding on this topic is limited to usage in my projects, and I am well aware that you really don't know a part of the stack until you get to a point where you could write or have written that part of the stack. Thanks for reading.

from tz.js.

coolaj86 avatar coolaj86 commented on August 19, 2024

I don't think it's a bad idea, but I don't think it's useful enough over the current structure to warrant an API change.

{
  // date
  "year": 2021, "month": 2, "day": 14,
  // time
  "hour": 3, "minute": 15, "second": 59, "millisecond": 0,
  // tz
  "offset": -240, "timeZoneName": "Eastern Daylight Time"
}

from tz.js.

Related Issues (6)

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.