-
-
Notifications
You must be signed in to change notification settings - Fork 670
feat: implemented getters / setters and various string fns on Date #1768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, instead split
better use indexOf
+ two substring
s here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that there would still be other avoidable allocations then when substring
ing 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this one to you @MaxGraey ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ColinEberhardt ok =)
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 https://github.com/ColinEberhardt/assemblyscript-temporal The only reason I am adding UTC-related |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the merge conflict fixed. We may also want to update the docs accordingly as a follow-up, and do a pass on String#split
afterwards :)
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 😆toISOString
I've also modified
Date.UTC
so that it no longer calls out to the JS host.