Comments (9)
OK 4.6.0 should accept any number of decimal fractions, but only up to three will be used.
from edtf.js.
I don't have the ISO 8601 standard by hand, but I've only ever seen strings with three-digit milliseconds. The parser is supposed to accept only valid ISO date strings so I think that throwing an error in the example above is the expected result. The JS Date
constructor allows some non-ISO formats which this parser has to reject.
from edtf.js.
Experimenting with this a little bit: (new Date('2024-01-10T14:17:32.1234Z')).toISOString()
gives '2024-01-10T14:17:32.123Z'
so the JS implementation also rounds the ISO format to three digits. .getMilliseconds()
also is 123 so it's not only that the ISO format drops the number but that the parser ignores it silently.
from edtf.js.
Yep, you're absolutely right! I guess you could consider adding a 'non-strict' mode, but I would also understand if you wouldn't ;)
from edtf.js.
Right, we sort of hijacked the extension levels for this already. There is a level 3 (the standard only goes to level 2) where we added some extra features. We could make the parser accept more sub-second precision there. However, even if the parser accepted the extra precision the rest of the API is built on top of the standard Date
object for storage which doesn't store the extra digits. That is, if you used anything but zeroes that information would be parsed and lost. Therefore, to support this properly I think we'd have to store the milliseconds separately, which I think we should only do if there's a strong reason for it.
Where do you get these date strings from?
from edtf.js.
Where do you get these date strings from?
A Media Asset Management system that does not take standards compliance seriously, as there are many unfortunately. However, we also get a lot of xsd:dateTime
and its unclear whether the XSD spec disallows this.
This is from the ISO 8601:2004 spec btw (I don't have access, but I got it from https://stackoverflow.com/questions/25842840/representing-fraction-of-second-with-iso-86012004):
4.2.2.4 Representations with decimal fraction
The interchange parties, dependent upon the application, shall agree the number of digits in the decimal fraction. The format shall be [hhmmss,ss], [hhmm,mm] or [hh,hh] as appropriate (hour minute second, hour minute, and hour, respectively), with as many digits as necessary following the decimal sign. A decimal fraction shall have at least one digit.
So the three digit limit might be a convention rather than a rule
from edtf.js.
OK in that case we can probably amend the grammar without doing any harm.
from edtf.js.
Though, as I said the underlying JS Date
will likely just drop any extra digits there.
from edtf.js.
sure, but then at least they can be parsed. Thanks!
from edtf.js.
Related Issues (20)
- License acquisition HOT 5
- Update to support latest spec HOT 3
- Inconsistent behavior for iterators on unspecified dates HOT 3
- February 29th on unspecified year HOT 2
- Year zero not treated as a leap year HOT 3
- Mismatches for XXXX-X2-<29+>
- -1XXX has incorrect min / max HOT 2
- Lists with continuations not parsing correctly HOT 2
- Usage in closed-source commercial product HOT 3
- Switch to ESM for good
- global is not defined HOT 10
- AssertionError when calling edtf("{1978,1988}") in prod HOT 13
- Day not considered unspecified in month-precision Level 0 date HOT 2
- JSON-schema validator HOT 9
- locale load can't be bundled anymore HOT 5
- allowing uaSymbol on undefined dates HOT 4
- minimal node example not loading HOT 11
- Invalid upper bound with dates before 1970-01-01 HOT 4
- Use unassert to remove assert in release builds HOT 6
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 edtf.js.