Comments (6)
I am also seeing this issue with date strings of form '09-15' -> DD-D; expected MM-DD (moment treats as MM-DD).
Similarly, inputs for '09' -> DD (moment treats as MM) and '12' -> D (moment treats as MM).
And 'March 28, 2001' -> MMMM D, YYYY (this may be technically ok but I would think a better result would be MMMM DD, YYYY).
from moment-parseformat.
I don’t think that 09-15
or 09
would be useful input to be parsed with this library. I’d be okay to add proper parsing for YYYY M D
/ YYYY MM DD
, although I have never seen this date format myself and given the issue is open for so long and nobody adding their +1s, it’s maybe too much of an edge case to be considered.
from moment-parseformat.
@gr2m Thanks for the quick reply. I think I misunderstood the purpose of this library. I am looking for a library that exposes the internal momentjs format string used to interpret the input if it (momentjs) determines that input to be a valid date string (i.e. return a format string consistent with a valid momentjs date string - which can be more forgiving than strict ISO8601 strings). Do I understand correctly that this is not the intention of moment-parseformat?
from moment-parseformat.
I am looking for a library that exposes the internal momentjs format string used to interpret the input if it (momentjs) determines that input to be a valid date string
I think momentjs is just passing the string to the native Date
object that might or might not be able to parse the string correctly, it’s different based on the JavaScript runtime environment. I don’t think you can get access to the input format used to parse the string. This library is doing all the parsing by hand with lots and lots of regex :)
I use parseFormat to parse dates entered by humans. The idea is that someone can enter a date in a free text form and the app can understand both the entered date/time as well as the preferred date format of the user.
from moment-parseformat.
I think momentjs is just passing the string to the native Date object that might or might not be able to parse the string correctly
@gr2m Thanks. Yes, this makes sense and likely explains why momentjs does not seem to expose parsed date fields - even though they appear to have some notion of this in their parse flags object (_pf.parsedDateParts). It seems to be an empty array every time I check it.
I will spend more time with momentjs to try too understand it a bit better. There do appear to be cases where momentjs is making some attempt to interpret date strings before calling Date
on the string (e.g. a string of "2001" is interpreted as the year 2001 by momentjs but native Date
will interpret this as 2001 milliseconds). Perhaps this is a feature request better placed with momentjs - although the opaqueness of the native Date
object may impose significant challenges for fulfilling this request.
Thanks again!
from moment-parseformat.
Keep me posted :) I’ll close this issue for the time being, maybe open a new issue if you have a plan™️
from moment-parseformat.
Related Issues (20)
- Su_2016_Aug_3 → Su_YYYY_MMM_D HOT 9
- package.json is missing version HOT 3
- today → today HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 2
- Incorrect Date Conversion in nodered, moment.js in javascript works fine. HOT 2
- An in-range update of semantic-release is breaking the build 🚨 HOT 2
- 2018/12/30 12:00 → YYYY/MM/DD H:mm; HOT 1
- The automated release is failing 🚨
- https://api.tookanapp.com/ → https://api.tookanapp.com/
- Month and year only formats identified as date and year formats HOT 1
- Beyond 3DP seconds causes incorrect format output HOT 5
- The automated release is failing 🚨 HOT 8
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- An in-range update of rimraf is breaking the build 🚨 HOT 1
- Obtain all possible formats HOT 3
- Suggestion to make 3.1.0 release a major version update 4.0.0 HOT 5
- 2021-11-29 → YYYY-MM-DD
- 2022年9月3日 凌晨1点 → YYYY年D月3日 凌晨1点
- 29-Feb-2024 → D-MMMZ HOT 4
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 moment-parseformat.