Skip to content

On the naïveness of time #1

@Enet4

Description

@Enet4

As far as I understand it, the naive module bears the semantic of lack of time-zone awareness. That is, types also bear a specific time zone unless it's a Naive variant. However, it has been suggested that this may bring some confusion. Namely:

  • There is a NaiveTime type, but no Time. I would invite the community to think whether this value with a timezone is useful enough to earn a dedicated type.
  • There is a Date type with a time zone, which does not make sense without the rest of the time instance, but it is useful as an intermediate result for the current builder pattern:
let dt = Utc.ymd(2014, 11, 28) // Date<Utc>
    .and_hms_milli(7, 8, 9, 10); // DateTime<Utc>

However, this intermediate type can be avoided if we start from a NaiveDate and add a (currently unexistent) with_timezone method. The deprecation of Date<Tz> has been hinted here too.

let dt = NaiveDate::from_ymd(2014, 11, 28) // NaiveDate
    .and_hms_milli(7, 8, 9, 10) // NaiveDateTime
    .with_timezone(Utc); // DateTime<Utc>

This makes me think that "naiveness" in this context could only be applied to a complete time instant: date plus time. And if so, the meaning of a Naive prefix in either a Date or a Time might just become void. I would like to use this issue to discuss and establish a clearer meaning and purpose of the naive module.

  1. Should NaiveTime become just Time, thus discarding the possiblity of time instances with time zone awareness? I wrote a backwards-compatible proof of concept in this branch.
  2. Should Date stay as it is in 1.0, or should it become a type without a time zone? Are there any benefits of this type other than enabling building a DateTime using the time zone type as the starting point?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions