Skip to content

Reconsider names for TimeZoneVariant enum #6701

@sffc

Description

@sffc

They are currently Standard and Daylight.

The naming of "standard" is unfortunate, because it looks like something one might reach for when they need a default. In reality, this can never be defaulted, because it is the result of a TZDB calculation. Defaulting to one can produce results that are not just incomprehensible but actually wrong, like showing 8pm instead of 7pm. It is therefore our duty as API designers to prevent programmers from using Standard when they need a default value.

In Rust, we've done this in two ways:

  1. Not adding a default on the enum, even when people try to add one (Add explicit defaults to FFI enums where clear-cut. #6692)
  2. Typically not requiring a variant, instead allowing it to be omitted or passed as an Option

However, we should try to do better.

I think we're stuck with the status quo for 2.0, but we should consider in 3.0 whether we want to adopt new names, such as:

// Option 0: Status quo
// Pro: Consistent with US time zone naming conventions
// Con: Misleading names that are wrong for e.g. Irish Standard Time
// Con: The name "standard" sounds like it wants to be a default
pub enum TimeZoneVariant {
    Standard,
    Daylight,
}

// Option 1: Season-based
// Pro: Easy to understand; almost always correct, even in Ireland
// Con: Doesn't work in Morocco which uses Summer time year-round
//      except during Ramadan
pub enum TimeZoneVariant {
    WinterOrYearRound,
    Summer,
}

// Option 2: Offset-based
// Pro: Always correct, precisely reflects the CLDR definition
// Con: Hard to understand
pub enum TimeZoneVariant {
    LowerOffset,
    HigherOffset,
}

// Option 3: Sunrise-based
// Pro: Somewhat easy to understand
// Con: Could be confusing since sunrise in Summer is earlier than in Winter
//      despite using the LaterSunrise variant
pub enum TimeZoneVariant {
    EarlierSunrise,
    LaterSunrise,
}

// Option 4: Meridian-based
// Pro: Somewhat easy to understand
// Con: What is a meridian?
pub enum TimeZoneVariant {
    EarlierMeridian,
    LaterMeridian,
}

@robertbastian @Manishearth

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-time-zoneComponent: Time ZonesdiscussDiscuss at a future ICU4X-SC meeting

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions