Comments (13)
@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.
@iamkun βοΈ I will try to build one.
from dayjs.
@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.
maybe some one need this feature, but still I recommend using ISO date format always.
from dayjs.
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.
@atomfrede That would be nice. Besides, a plugin might be better. e.g. customFormatParser
from dayjs.
@atomfrede Cheers
from dayjs.
I also started using this till i found out that i can't parse back to date from my format.
from dayjs.
There are two usage scenarios for parsing in my application:
- Construct
dayjs
from a persistent storage. The strings come in the fixed ISO format. No problem. - 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.
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.
Sometimes, the date is user provided.
Also, is pretty strange that both '2005-02-18' and '02-18-2018' are valid dates.
from dayjs.
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.
π CustomParseFormat plugin is supported and included in version 1.8.0 π
The release is available on:
from dayjs.
Related Issues (20)
- isSame() returns true when comparing a certain date to undefined HOT 1
- Ordinal not work in zh, ja language
- In Safari, parsing "2024 7 1" with format "YYYY M D" fails, but "2024/7/1" with format "YYYY/M/D" succeeds HOT 5
- dayjs.duration() incorrect result
- dayjs.duration() improvement
- Locale parsing with unmatched dash locale overrides global
- Named export 'Dayjs' not found. The requested module 'dayjs' is a CommonJS module, which may not support all module.exports as named exports. HOT 1
- TimeZone conversion gives different output as compared to moment
- Parse format DD-MM-YYYY is interpreted as MM-DD-YYYY HOT 2
- Wrong timezone conversion when tz != browser tz
- GTM timezone is not handled correctly
- Dayjs subtract does not support week based dayjs durations => expected?
- The function "format" would be broken after "utcOffset" being invoked twice and more
- Return Timezone list ? HOT 2
- ζΆι΄θ·ειθ―― HOT 2
- Dayjs considers Saturday to be the first day of week i.e. date.day() == 0 for Saturday
- Parse date string with timeZone invalid in strict mode
- Locale FI - breaks from other languages in relative time format
- Many issues with dates under year 100 (0099 ... 0001, 0000, -0001, -0002, ...)
- utc plugin requires specification of parsing format HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dayjs.