Coder Social home page Coder Social logo

Constructor with custom format about dayjs HOT 13 CLOSED

iamkun avatar iamkun commented on May 7, 2024 11
Constructor with custom format

from dayjs.

Comments (13)

pablomaurer avatar pablomaurer commented on May 7, 2024 7

@iamkun Yep using ISO would format is a great advice, but some (me :D) have to deal with data from other sources which doesn't support the ISO date format.

from dayjs.

atomfrede avatar atomfrede commented on May 7, 2024 6

@iamkun βœ”οΈ I will try to build one.

from dayjs.

prantlf avatar prantlf commented on May 7, 2024 4

@atomfrede, you can have a look at #340. It is my (unfinished) implementation. Only alpha-numeric non-localizable format tokens are supported, which are usually the only ones needed in enterprise applications. Recognition of localizable tokens, like "January" is missing.

from dayjs.

iamkun avatar iamkun commented on May 7, 2024 1

maybe some one need this feature, but still I recommend using ISO date format always.

from dayjs.

atomfrede avatar atomfrede commented on May 7, 2024

Is someone working in that feature (if not I can try to do it), as I try to get rid of moment in https://www.jhipster.tech/ which is part of the react validation lib which relies on that specific moment api (moment('2018-02-01', 'YYYY-DD-MM')) to check if the date entered in a component is a valid date (and conforms the specified format).

from dayjs.

iamkun avatar iamkun commented on May 7, 2024

@atomfrede That would be nice. Besides, a plugin might be better. e.g. customFormatParser

from dayjs.

iamkun avatar iamkun commented on May 7, 2024

@atomfrede Cheers

from dayjs.

alanaasmaa avatar alanaasmaa commented on May 7, 2024

I also started using this till i found out that i can't parse back to date from my format.

from dayjs.

prantlf avatar prantlf commented on May 7, 2024

There are two usage scenarios for parsing in my application:

  1. Construct dayjs from a persistent storage. The strings come in the fixed ISO format. No problem.
  2. Construct dayjs from the date picker output. The strings come in a customizable user-specific format. Big problem.

The second scenario needs a custom parsing.

@atomfrede, thanks, you'll save me time to implement the customFormatParser myself :-) After the three PRs I posted, this is the last feature that I need to start using Day.js instead of Moment.js.

from dayjs.

dmydry avatar dmydry commented on May 7, 2024

Hey guys! @iamkun thanks for so lightweight lib.
@prantlf great and so wanted feature! waiting for your pr to be approved and merged.

from dayjs.

robsonsobral avatar robsonsobral commented on May 7, 2024

Sometimes, the date is user provided.

Also, is pretty strange that both '2005-02-18' and '02-18-2018' are valid dates.

from dayjs.

iwantwin avatar iwantwin commented on May 7, 2024

I'm dying to use this library instead of momentjs! But I really need this feature to be implemented before I can switch. Bundle size & tree shaking means a lot at the moment.. ;)

If anyone is working on it, let me know if and how I can help :)

from dayjs.

iamkun avatar iamkun commented on May 7, 2024

πŸŽ‰ CustomParseFormat plugin is supported and included in version 1.8.0 πŸŽ‰

The release is available on:

from dayjs.

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.