-
Notifications
You must be signed in to change notification settings - Fork 59
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
Export TzOffset #117
Export TzOffset #117
Conversation
ee241fa
to
4825f6d
Compare
This question was brought up before in #35 but the asker closed it there after finding a workaround for their use-case. |
I became the maintainer for this crate a few months ago and haven't had time to dig in all that much beyond some version bumps. Thus, I don't have any context in my head around @LucioFranco any opinions? |
@djc Your wariness makes sense. I don't personally have any rush for this as I'm happy with using my branch of My specific use case is building a wrapper type that unifies /// iCal times and datetimes can either have a specific time zone or be considered "floating", i.e.
/// assumed to be in the current local timezone. Specific time zones can be either UTC or some
/// named time zone such as "America/New York". This enum models specific time zones as a wrapped
/// [`chrono_tz::Tz`] and floating time zones are just a [`chrono::Local`] under the hood.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Zone {
Floating,
Named(chrono_tz::Tz),
} This enum type is fine but the trick is in implementing impl TimeZone for Zone {
type Offset = ZoneOffset;
// ...
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum ZoneOffset {
Floating(chrono::FixedOffset),
Named(chrono_tz::TzOffset),
}
impl Offset for ZoneOffset {
fn fix(&self) -> chrono::FixedOffset {
match self {
Self::Floating(offset) => *offset,
Self::Named(tzoffset) => tzoffset.fix(),
}
}
} Using my branch via a |
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.
This makes sense to me. There is no reason it should be private, seems like an oversight.
We currently document TzOffset
as part of our public API via the TimeZone
trait, the OffsetComponents
and OffsetName
traits. But the type itself doesn't show up in the documentation.
B.t.w. I wonder why we even have OffsetComponents
and OffsetName
traits, as all they do is add some methods to TzOffset
. Maybe their only reason for existence is that the methods would not be discoverable on a private TzOffset
?
f03cf8e
to
1c6bc3c
Compare
Thank you @mjdwitt! |
This type is included in the
Tz
's implementation ofTimeZone
and not exporting it makes it difficult to work withTz
in wrapper types. Are there changes planned for this type that preclude it from being exported or is this okay?