feat: implemented getters / setters and various string fns on Date #1768
feat: implemented getters / setters and various string fns on Date #1768dcodeIO merged 6 commits intoAssemblyScript:masterfrom
Conversation
101144e to
56dab26
Compare
|
|
||
| if (dateTimeString.includes("T")) { | ||
| // includes a time component | ||
| const parts = dateTimeString.split("T"); |
There was a problem hiding this comment.
There may be an opportunity here to make fromString basically allocation-free, by walking the string and using strtol to extract the values (currently doesn't support a limit, though). @MaxGraey Thoughts?
There was a problem hiding this comment.
yeah, instead split better use indexOf + two substrings here
There was a problem hiding this comment.
Note that there would still be other avoidable allocations then when substringing the parts of interest into parseInt. Hence I thought this may be a case for slightly extending strtol so it stops at a given limit :)
There was a problem hiding this comment.
I'll leave this one to you @MaxGraey ;-)
|
A tiny recommendations - add peace of mind for checking the odd corner cases in dates in different timezones. Perhaps add |
Thanks @bnbarak - I don't plan to add any timezone related functionality to The only reason I am adding UTC-related |
b622444 to
5f236a4
Compare
Thanks @dcodeIO - rebased onto I'll update the docs after this is merged. |
since AssemblyScript/assemblyscript#1768 is merged we can safely remove relative import hack
since AssemblyScript/assemblyscript#1768 is merged we can safely remove relative import hack
since AssemblyScript/assemblyscript#1768 is merged we can safely remove relative import hack
Adding functionality from AssemblyScript/assemblyscript#1768
Adding functionality from AssemblyScript/assemblyscript#1768
This PR adds
fromString, as a substitute for thenew Date("2345-11-04")style constructor - I resisted the temptation to use as-regex for this task 😆toISOStringI've also modified
Date.UTCso that it no longer calls out to the JS host.