-
Notifications
You must be signed in to change notification settings - Fork 101
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
Implement parsing and formatting for Instant as separate functions #411
base: uniform-ranges
Are you sure you want to change the base?
Conversation
71fc711
to
fd78536
Compare
core/native/src/Instant.kt
Outdated
total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400 | ||
} else { | ||
total -= y / -4 - y / -100 + y / -400 |
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.
Looks like a case for ceilDiv in stdlib :)
fd78536
to
019c71b
Compare
private fun parseInstant(isoString: String): Instant { | ||
// return Instant.parse(isoString) | ||
return parseIso(isoString) | ||
} | ||
|
||
private fun displayInstant(instant: Instant): String { | ||
// return instant.toString() | ||
return formatIso(instant) | ||
} |
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.
@qurbonzoda, here's the logic behind this PR: the newly-added formatIso
can replace toString
, and the newly-added parseIso
can replace Instant.parse
in the case when no specific format is passed (which is the only case supported by `kotlin.time.Instant).
023b7ac
to
ece4e11
Compare
Implement parsing and formatting of ISO strings for instant values separately from the rest of the library.
A stage of fixing #382
This is a draft PR because we probably don't need to actually merge it into the datetime library. However, the code is already written and can be reviewed.