Skip to content

Commit f80164a

Browse files
nekevssManishearth
andauthored
Rename timezone.rs to time_zone.rs (#574)
Closes #455 One final module review update for consistency. 😄 This should mark the end of the general module review. --------- Co-authored-by: Manish Goregaokar <[email protected]>
1 parent 79355d3 commit f80164a

File tree

11 files changed

+32
-30
lines changed

11 files changed

+32
-30
lines changed

src/builtins/core/duration/normalized.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::{cmp, num::NonZeroU128, ops::Add};
55
use num_traits::AsPrimitive;
66

77
use crate::{
8-
builtins::core::{timezone::TimeZone, PlainDate, PlainDateTime},
8+
builtins::core::{time_zone::TimeZone, PlainDate, PlainDateTime},
99
iso::{IsoDate, IsoDateTime},
1010
options::{
1111
Disambiguation, Overflow, ResolvedRoundingOptions, RoundingIncrement, RoundingMode, Unit,
@@ -372,7 +372,7 @@ impl InternalDurationRecord {
372372
sign: Sign,
373373
dest_epoch_ns: i128,
374374
dt: &PlainDateTime,
375-
tz: Option<(&TimeZone, &impl TimeZoneProvider)>, // ???
375+
time_zone: Option<(&TimeZone, &impl TimeZoneProvider)>, // ???
376376
options: ResolvedRoundingOptions,
377377
) -> TemporalResult<NudgeRecord> {
378378
// NOTE: r2 may never be used...need to test.
@@ -584,13 +584,13 @@ impl InternalDurationRecord {
584584
let end = IsoDateTime::new_unchecked(end.iso, dt.iso.time);
585585

586586
// 12. Else,
587-
let (start_epoch_ns, end_epoch_ns) = if let Some((tz, provider)) = tz {
587+
let (start_epoch_ns, end_epoch_ns) = if let Some((time_zone, provider)) = time_zone {
588588
// a. Let startEpochNs be ? GetEpochNanosecondsFor(timeZone, startDateTime, compatible).
589589
// b. Let endEpochNs be ? GetEpochNanosecondsFor(timeZone, endDateTime, compatible).
590590
let start_epoch_ns =
591-
tz.get_epoch_nanoseconds_for(start, Disambiguation::Compatible, provider)?;
591+
time_zone.get_epoch_nanoseconds_for(start, Disambiguation::Compatible, provider)?;
592592
let end_epoch_ns =
593-
tz.get_epoch_nanoseconds_for(end, Disambiguation::Compatible, provider)?;
593+
time_zone.get_epoch_nanoseconds_for(end, Disambiguation::Compatible, provider)?;
594594
(start_epoch_ns.ns, end_epoch_ns.ns)
595595
// 11. If timeZoneRec is unset, then
596596
} else {
@@ -658,7 +658,7 @@ impl InternalDurationRecord {
658658
&self,
659659
sign: Sign,
660660
dt: &PlainDateTime,
661-
tz: &TimeZone,
661+
time_zone: &TimeZone,
662662
options: ResolvedRoundingOptions,
663663
provider: &impl TimeZoneProvider,
664664
) -> TemporalResult<NudgeRecord> {
@@ -681,9 +681,11 @@ impl InternalDurationRecord {
681681
// 4. Let endDateTime be CombineISODateAndTimeRecord(endDate, isoDateTime.[[Time]]).
682682
let end_dt = IsoDateTime::new_unchecked(end_date, dt.iso.time);
683683
// 5. Let startEpochNs be ? GetEpochNanosecondsFor(timeZone, startDateTime, compatible).
684-
let start = tz.get_epoch_nanoseconds_for(start_dt, Disambiguation::Compatible, provider)?;
684+
let start =
685+
time_zone.get_epoch_nanoseconds_for(start_dt, Disambiguation::Compatible, provider)?;
685686
// 6. Let endEpochNs be ? GetEpochNanosecondsFor(timeZone, endDateTime, compatible).
686-
let end = tz.get_epoch_nanoseconds_for(end_dt, Disambiguation::Compatible, provider)?;
687+
let end =
688+
time_zone.get_epoch_nanoseconds_for(end_dt, Disambiguation::Compatible, provider)?;
687689
// 7. Let daySpan be TimeDurationFromEpochNanosecondsDifference(endEpochNs, startEpochNs).
688690
let day_span = TimeDuration::from_nanosecond_difference(end.ns.0, start.ns.0)?;
689691
// 8. Assert: TimeDurationSign(daySpan) = sign.
@@ -1012,19 +1014,19 @@ impl InternalDurationRecord {
10121014
&self,
10131015
dest_epoch_ns: i128,
10141016
dt: &PlainDateTime,
1015-
tz: Option<(&TimeZone, &impl TimeZoneProvider)>,
1017+
time_zone: Option<(&TimeZone, &impl TimeZoneProvider)>,
10161018
unit: Unit,
10171019
) -> TemporalResult<FiniteF64> {
10181020
// 1. If IsCalendarUnit(unit) is true, or timeZone is not unset and unit is day, then
1019-
if unit.is_calendar_unit() || (tz.is_some() && unit == Unit::Day) {
1021+
if unit.is_calendar_unit() || (time_zone.is_some() && unit == Unit::Day) {
10201022
// a. Let sign be InternalDurationSign(duration).
10211023
let sign = self.sign();
10221024
// b. Let record be ? NudgeToCalendarUnit(sign, duration, destEpochNs, isoDateTime, timeZone, calendar, 1, unit, trunc).
10231025
let record = self.nudge_calendar_unit(
10241026
sign,
10251027
dest_epoch_ns,
10261028
dt,
1027-
tz,
1029+
time_zone,
10281030
ResolvedRoundingOptions {
10291031
largest_unit: unit,
10301032
smallest_unit: unit,

src/builtins/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
pub mod calendar;
1010
pub mod duration;
11-
pub mod timezone;
11+
pub mod time_zone;
1212

1313
mod instant;
1414
mod plain_date;

src/builtins/core/now.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::TemporalResult;
55
use crate::{host::HostHooks, provider::TimeZoneProvider};
66

77
use super::{
8-
calendar::Calendar, timezone::TimeZone, Instant, PlainDate, PlainDateTime, PlainTime,
8+
calendar::Calendar, time_zone::TimeZone, Instant, PlainDate, PlainDateTime, PlainTime,
99
ZonedDateTime,
1010
};
1111

src/builtins/core/plain_date.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ impl PlainDate {
655655
#[inline]
656656
pub fn to_zoned_date_time_with_provider(
657657
&self,
658-
tz: TimeZone,
658+
time_zone: TimeZone,
659659
plain_time: Option<PlainTime>,
660660
provider: &impl TimeZoneProvider,
661661
) -> TemporalResult<ZonedDateTime> {
@@ -667,16 +667,16 @@ impl PlainDate {
667667
// c. If ISODateTimeWithinLimits(isoDateTime) is false, throw a RangeError exception.
668668
let result_iso = IsoDateTime::new(self.iso, time.iso)?;
669669
// d. Let epochNs be ? GetEpochNanosecondsFor(timeZone, isoDateTime, compatible).
670-
tz.get_epoch_nanoseconds_for(result_iso, Disambiguation::Compatible, provider)?
670+
time_zone.get_epoch_nanoseconds_for(result_iso, Disambiguation::Compatible, provider)?
671671
// 5. If temporalTime is undefined, then
672672
} else {
673673
// a. Let epochNs be ? GetStartOfDay(timeZone, temporalDate.[[ISODate]]).
674-
tz.get_start_of_day(&self.iso, provider)?
674+
time_zone.get_start_of_day(&self.iso, provider)?
675675
};
676676
// 7. Return ! CreateTemporalZonedDateTime(epochNs, timeZone, temporalDate.[[Calendar]]).
677677
ZonedDateTime::try_new_with_cached_offset(
678678
epoch_ns.ns.0,
679-
tz,
679+
time_zone,
680680
self.calendar.clone(),
681681
epoch_ns.offset,
682682
)
@@ -947,9 +947,9 @@ mod tests {
947947
use timezone_provider::tzif::FsTzdbProvider;
948948
let provider = &FsTzdbProvider::default();
949949
let date = PlainDate::from_str("2020-01-01").unwrap();
950-
let tz = TimeZone::try_from_str_with_provider("UTC", provider).unwrap();
950+
let time_zone = TimeZone::try_from_str_with_provider("UTC", provider).unwrap();
951951
let zdt = date
952-
.to_zoned_date_time_with_provider(tz, None, provider)
952+
.to_zoned_date_time_with_provider(time_zone, None, provider)
953953
.unwrap();
954954
assert_eq!(zdt.year(), 2020);
955955
assert_eq!(zdt.month(), 1);
File renamed without changes.

src/builtins/core/zoned_date_time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
core::{
1313
calendar::Calendar,
1414
duration::normalized::{InternalDurationRecord, TimeDuration},
15-
timezone::{TimeZone, UtcOffset},
15+
time_zone::{TimeZone, UtcOffset},
1616
Duration, Instant, PlainDate, PlainDateTime, PlainTime,
1717
},
1818
},

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub mod fields {
348348
// TODO: Should we be exporting MonthCode and UtcOffset here.
349349
pub use crate::builtins::{
350350
calendar::{Calendar, MonthCode},
351-
core::timezone::{TimeZone, UtcOffset},
351+
core::time_zone::{TimeZone, UtcOffset},
352352
Duration, Instant, PlainDate, PlainDateTime, PlainMonthDay, PlainTime, PlainYearMonth,
353353
ZonedDateTime,
354354
};

src/options/relative_to.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! RelativeTo rounding option
22
33
use crate::builtins::core::zoned_date_time::interpret_isodatetime_offset;
4-
use crate::builtins::core::{calendar::Calendar, timezone::TimeZone, PlainDate, ZonedDateTime};
4+
use crate::builtins::core::{calendar::Calendar, time_zone::TimeZone, PlainDate, ZonedDateTime};
55
use crate::iso::{IsoDate, IsoTime};
66
use crate::options::{Disambiguation, OffsetDisambiguation, Overflow};
77
use crate::parsers::{parse_date_time, parse_zoned_date_time};
@@ -65,7 +65,7 @@ impl RelativeTo {
6565
// iv. Set matchBehaviour to match-minutes.
6666
let mut match_minutes = true;
6767

68-
let timezone = TimeZone::from_time_zone_record(annotation.tz, provider)?;
68+
let time_zone = TimeZone::from_time_zone_record(annotation.tz, provider)?;
6969

7070
let (offset_nanos, is_exact) = result
7171
.offset
@@ -111,7 +111,7 @@ impl RelativeTo {
111111
time,
112112
is_exact,
113113
offset_nanos,
114-
&timezone,
114+
&time_zone,
115115
Disambiguation::Compatible,
116116
OffsetDisambiguation::Reject,
117117
match_minutes,
@@ -120,7 +120,7 @@ impl RelativeTo {
120120

121121
Ok(ZonedDateTime::try_new_with_cached_offset(
122122
epoch_ns.ns.0,
123-
timezone,
123+
time_zone,
124124
calendar,
125125
epoch_ns.offset,
126126
)?

src/parsed_intermediates.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl ParsedZonedDateTime {
145145
let annotation = parse_result.tz.temporal_unwrap()?;
146146

147147
// e. Let timeZone be ? ToTemporalTimeZoneIdentifier(annotation).
148-
let timezone = TimeZone::from_time_zone_record(annotation.tz, provider)?;
148+
let time_zone = TimeZone::from_time_zone_record(annotation.tz, provider)?;
149149

150150
// f. Let offsetString be result.[[TimeZone]].[[OffsetString]].
151151
let (offset, has_utc_designator) = match parse_result.offset {
@@ -185,7 +185,7 @@ impl ParsedZonedDateTime {
185185
has_utc_designator,
186186
match_minutes,
187187
offset,
188-
timezone,
188+
timezone: time_zone,
189189
})
190190
}
191191
}

src/parsers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use ixdtf::{
1212
};
1313
use writeable::{impl_display_with_writeable, LengthHint, Writeable};
1414

15-
mod timezone;
15+
mod time_zone;
1616

17-
pub(crate) use timezone::{parse_allowed_timezone_formats, parse_identifier};
17+
pub(crate) use time_zone::{parse_allowed_timezone_formats, parse_identifier};
1818

1919
// TODO: Move `Writeable` functionality to `ixdtf` crate
2020

0 commit comments

Comments
 (0)