-
Notifications
You must be signed in to change notification settings - Fork 182
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
Extend DateTimeFormat to support other calendars #1339
Conversation
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!
one n-b question is about using Deref
on generalized structs.
s | ||
#[inline] | ||
pub fn format_to_string(&self, value: &impl DateTimeInput<Calendar = C>) -> String { | ||
self.0.format_to_string(value) | ||
} |
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.
question
: can you Deref
to self.0
?
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.
Yes, but that would make self.0
a public part of the API.
Plus it's typically not considered good style to use Deref
for coercions when pointers aren't involved
Fixes #1316, fixes #1115
This implements the low level API discussed in #1316: There is a public
DateTimeFormat<C>
API withC
as a calendar type, and it is internally backed by a "raw"DateTimeFormat
type with the actual implementation (same goes for ZonedDateTimeFormat). Users must specify a calendar on construction and only dates which match the calendar type can be passed in. The raw API does no such checking and is meant to be a building block for the eventual higher level API discussed in #1316.Todo (I plan to finish these items today, just wanted to have a PR up before lunch)
Unfortunately it is not yet worth it to properly test this since the Buddhist calendar has identical symbols to the Gregorian one, aside from era formatting which is not yet supported (#1312, I might work on this next).
I did verify that this PR works and loads data from the correct spot by modifying some month names in the CLDR data, regenerating testdata, and running the
work_log
example: