Skip to content

Commit d804513

Browse files
authored
Make ISO getters crate private (#568)
Closes #566 This PR removes the ISO getters from the public facing API. I did end up keeping them for crate private because they are nice short hand for dt.iso.date.year, etc. Per the issue, removing these from the public API will open a question about debug printing over FFI that we should probably have a plan for prior to merging.
1 parent 7a34200 commit d804513

20 files changed

+74
-302
lines changed

src/builtins/core/month_day.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,22 @@ impl PlainMonthDay {
177177
Self { iso, calendar }
178178
}
179179

180+
/// Returns the ISO month value of `PlainMonthDay`.
181+
#[inline]
182+
#[must_use]
183+
pub(crate) fn iso_month(&self) -> u8 {
184+
self.iso.month
185+
}
186+
187+
/// Returns the ISO year value of `PlainMonthDay`.
188+
#[inline]
189+
#[must_use]
190+
pub(crate) fn iso_year(&self) -> i32 {
191+
self.iso.year
192+
}
193+
}
194+
195+
impl PlainMonthDay {
180196
/// Creates a new valid `PlainMonthDay`.
181197
#[inline]
182198
pub fn new_with_overflow(
@@ -272,27 +288,6 @@ impl PlainMonthDay {
272288
.month_day_from_fields(merged, overflow.unwrap_or(Overflow::Constrain))
273289
}
274290

275-
/// Returns the ISO day value of `PlainMonthDay`.
276-
#[inline]
277-
#[must_use]
278-
pub fn iso_day(&self) -> u8 {
279-
self.iso.day
280-
}
281-
282-
// Returns the ISO month value of `PlainMonthDay`.
283-
#[inline]
284-
#[must_use]
285-
pub fn iso_month(&self) -> u8 {
286-
self.iso.month
287-
}
288-
289-
// Returns the ISO year value of `PlainMonthDay`.
290-
#[inline]
291-
#[must_use]
292-
pub fn iso_year(&self) -> i32 {
293-
self.iso.year
294-
}
295-
296291
/// Returns the string identifier for the current `Calendar`.
297292
#[inline]
298293
#[must_use]

src/builtins/core/plain_date.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,27 @@ impl PlainDate {
310310
fn days_until(&self, other: &Self) -> i32 {
311311
other.iso.to_epoch_days() - self.iso.to_epoch_days()
312312
}
313+
314+
/// Returns this `PlainDate`'s ISO year value.
315+
#[inline]
316+
#[must_use]
317+
pub(crate) const fn iso_year(&self) -> i32 {
318+
self.iso.year
319+
}
320+
321+
/// Returns this `PlainDate`'s ISO month value.
322+
#[inline]
323+
#[must_use]
324+
pub(crate) const fn iso_month(&self) -> u8 {
325+
self.iso.month
326+
}
327+
328+
/// Returns this `PlainDate`'s ISO day value.
329+
#[inline]
330+
#[must_use]
331+
pub(crate) const fn iso_day(&self) -> u8 {
332+
self.iso.day
333+
}
313334
}
314335

315336
// ==== Public API ====
@@ -432,27 +453,6 @@ impl PlainDate {
432453
Self::new_unchecked(self.iso, calendar)
433454
}
434455

435-
#[inline]
436-
#[must_use]
437-
/// Returns this `PlainDate`'s ISO year value.
438-
pub const fn iso_year(&self) -> i32 {
439-
self.iso.year
440-
}
441-
442-
#[inline]
443-
#[must_use]
444-
/// Returns this `PlainDate`'s ISO month value.
445-
pub const fn iso_month(&self) -> u8 {
446-
self.iso.month
447-
}
448-
449-
#[inline]
450-
#[must_use]
451-
/// Returns this `PlainDate`'s ISO day value.
452-
pub const fn iso_day(&self) -> u8 {
453-
self.iso.day
454-
}
455-
456456
#[inline]
457457
#[must_use]
458458
/// Returns a reference to this `PlainDate`'s calendar slot.

src/builtins/core/plain_date_time.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,27 @@ impl PlainDateTime {
345345
unit,
346346
)
347347
}
348+
349+
/// Returns this `PlainDateTime`'s ISO year value.
350+
#[inline]
351+
#[must_use]
352+
pub const fn iso_year(&self) -> i32 {
353+
self.iso.date.year
354+
}
355+
356+
/// Returns this `PlainDateTime`'s ISO month value.
357+
#[inline]
358+
#[must_use]
359+
pub const fn iso_month(&self) -> u8 {
360+
self.iso.date.month
361+
}
362+
363+
/// Returns this `PlainDateTime`'s ISO day value.
364+
#[inline]
365+
#[must_use]
366+
pub const fn iso_day(&self) -> u8 {
367+
self.iso.date.day
368+
}
348369
}
349370

350371
// ==== Public PlainDateTime API ====
@@ -664,27 +685,6 @@ impl PlainDateTime {
664685
Self::new_unchecked(self.iso, calendar)
665686
}
666687

667-
/// Returns this `PlainDateTime`'s ISO year value.
668-
#[inline]
669-
#[must_use]
670-
pub const fn iso_year(&self) -> i32 {
671-
self.iso.date.year
672-
}
673-
674-
/// Returns this `PlainDateTime`'s ISO month value.
675-
#[inline]
676-
#[must_use]
677-
pub const fn iso_month(&self) -> u8 {
678-
self.iso.date.month
679-
}
680-
681-
/// Returns this `PlainDateTime`'s ISO day value.
682-
#[inline]
683-
#[must_use]
684-
pub const fn iso_day(&self) -> u8 {
685-
self.iso.date.day
686-
}
687-
688688
/// Returns the hour value
689689
#[inline]
690690
#[must_use]

src/builtins/core/year_month.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,20 @@ impl PlainYearMonth {
347347
DifferenceOperation::Until => Ok(result),
348348
}
349349
}
350+
351+
/// Returns the iso month value for this `YearMonth`.
352+
#[inline]
353+
#[must_use]
354+
pub(crate) fn iso_month(&self) -> u8 {
355+
self.iso.month
356+
}
357+
358+
/// Returns the iso year value for this `YearMonth`.
359+
#[inline]
360+
#[must_use]
361+
pub(crate) fn iso_year(&self) -> i32 {
362+
self.iso.year
363+
}
350364
}
351365

352366
// ==== Public method implementations ====
@@ -448,34 +462,13 @@ impl PlainYearMonth {
448462
.year_month_from_fields(fields, Overflow::Constrain)
449463
}
450464

451-
/// Returns the iso year value for this `YearMonth`.
452-
#[inline]
453-
#[must_use]
454-
pub fn iso_year(&self) -> i32 {
455-
self.iso.year
456-
}
457-
458465
/// Returns the padded ISO year string
459466
#[inline]
460467
#[must_use]
461468
pub fn padded_iso_year_string(&self) -> String {
462469
pad_iso_year(self.iso.year)
463470
}
464471

465-
/// Returns the iso month value for this `YearMonth`.
466-
#[inline]
467-
#[must_use]
468-
pub fn iso_month(&self) -> u8 {
469-
self.iso.month
470-
}
471-
472-
/// Returns the internal ISO day for this `YearMonth`.
473-
#[inline]
474-
#[must_use]
475-
pub fn iso_reference_day(&self) -> u8 {
476-
self.iso.day
477-
}
478-
479472
/// Returns the calendar era of the current `PlainYearMonth`
480473
pub fn era(&self) -> Option<TinyAsciiStr<16>> {
481474
self.calendar().era(&self.iso)

temporal_capi/bindings/c/PlainDate.h

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporal_capi/bindings/c/PlainDateTime.h

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporal_capi/bindings/c/PlainMonthDay.h

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporal_capi/bindings/c/PlainYearMonth.h

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporal_capi/bindings/cpp/temporal_rs/PlainDate.d.hpp

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporal_capi/bindings/cpp/temporal_rs/PlainDate.hpp

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)