Skip to content
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

Draft
wants to merge 3 commits into
base: uniform-ranges
Choose a base branch
from

Conversation

dkhalanskyjb
Copy link
Collaborator

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.

Comment on lines 173 to 175
total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400
} else {
total -= y / -4 - y / -100 + y / -400
Copy link
Member

@ilya-g ilya-g Oct 30, 2024

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 :)

@dkhalanskyjb dkhalanskyjb changed the base branch from master to uniform-ranges November 5, 2024 13:18
@dkhalanskyjb dkhalanskyjb changed the title Prepare Instant for entering the standard library Implement parsing and formatting for Instant as separate functions Nov 7, 2024
Comment on lines +401 to +409
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)
}
Copy link
Collaborator Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants