Struct Time
struct Time { ... }
A representation of civil "wall clock" time.
Conceptually, a Time value corresponds to the typical hours and minutes
that you might see on a clock. This type also contains the second and
fractional subsecond (to nanosecond precision) associated with a time.
Civil time
A Time value behaves as if it corresponds precisely to a single
nanosecond within a day, where all days have 86,400 seconds. That is,
any given Time value corresponds to a nanosecond in the inclusive range
[0, 86399999999999], where 0 corresponds to 00:00:00.000000000
(Time::MIN) and 86399999999999 corresponds to 23:59:59.999999999
(Time::MAX). Moreover, in civil time, all hours have the same number of
minutes, all minutes have the same number of seconds and all seconds have
the same number of nanoseconds.
Parsing and printing
The Time type provides convenient trait implementations of
std::str::FromStr and [std::fmt::Display]:
use Time;
let t: Time = "15:22:45".parse?;
assert_eq!;
# Ok::
A civil Time can also be parsed from something that contains a
time, but with perhaps other data (such as an offset or time zone):
use Time;
let t: Time = "2024-06-19T15:22:45-04[America/New_York]".parse?;
assert_eq!;
# Ok::
For more information on the specific format supported, see the
fmt::temporal module documentation.
Default value
For convenience, this type implements the Default trait. Its default
value is midnight. i.e., 00:00:00.000000000.
Leap seconds
Jiff does not support leap seconds. Jiff behaves as if they don't exist.
The only exception is that if one parses a time with a second component
of 60, then it is automatically constrained to 59:
use ;
let t: Time = "23:59:60".parse?;
assert_eq!;
# Ok::
Comparisons
The Time type provides both Eq and Ord trait implementations to
facilitate easy comparisons. When a time t1 occurs before a time t2,
then t1 < t2. For example:
use time;
let t1 = time;
let t2 = time;
assert!;
As mentioned above, Time values are not associated with timezones, and
thus transitions such as DST are not taken into account when comparing
Time values.
Arithmetic
This type provides routines for adding and subtracting spans of time, as
well as computing the span of time between two Time values.
For adding or subtracting spans of time, one can use any of the following routines:
Time::wrapping_addorTime::wrapping_subfor wrapping arithmetic.Time::checked_addorTime::checked_subfor checked arithmetic.Time::saturating_addorTime::saturating_subfor saturating arithmetic.
Additionally, wrapping arithmetic is available via the Add and Sub
trait implementations:
use ;
let t = time;
let span = 1.hours.minutes.seconds;
assert_eq!;
// Overflow will result in wrap-around unless using checked
// arithmetic explicitly.
let t = time;
assert_eq!;
Wrapping arithmetic is used by default because it corresponds to how clocks showing the time of day behave in practice.
One can compute the span of time between two times using either
Time::until or Time::since. It's also possible to subtract two
Time values directly via a Sub trait implementation:
use ;
let time1 = time;
let time2 = time;
assert_eq!;
The until and since APIs are polymorphic and allow re-balancing and
rounding the span returned. For example, the default largest unit is hours
(as exemplified above), but we can ask for smaller units:
use ;
let time1 = time;
let time2 = time;
assert_eq!;
# Ok::
Or even round the span returned:
use ;
let time1 = time;
let time2 = time;
assert_eq!;
// `TimeDifference` uses truncation as a rounding mode by default,
// but you can set the rounding mode to break ties away from zero:
assert_eq!;
# Ok::
Rounding
A Time can be rounded based on a TimeRound configuration of smallest
units, rounding increment and rounding mode. Here's an example showing how
to round to the nearest third hour:
use ;
let t = time;
assert_eq!;
// Or alternatively, make use of the `From<(Unit, i64)> for TimeRound`
// trait implementation:
assert_eq!;
# Ok::
See Time::round for more details.
Implementations
impl Time
fn strptime<impl AsRef<[u8]>: AsRef<[u8]>, impl AsRef<[u8]>: AsRef<[u8]>>(format: impl AsRef<[u8]>, input: impl AsRef<[u8]>) -> Result<Time, Error>Parses a civil time in
inputmatching the givenformat.The format string uses a "printf"-style API where conversion specifiers can be used as place holders to match components of a datetime. For details on the specifiers supported, see the
fmt::strtimemodule documentation.Errors
This returns an error when parsing failed. This might happen because the format string itself was invalid, or because the input didn't match the format string.
This also returns an error if there wasn't sufficient information to construct a civil time. For example, if an offset wasn't parsed.
Example
This example shows how to parse a civil time:
use Time; // Parse with a 12-hour clock. let time = strptime?; assert_eq!; # Ok::fn strftime<'f, F: 'f + ?Sized + AsRef<[u8]>>(self: &Self, format: &'f F) -> Display<'f>Formats this civil time according to the given
format.The format string uses a "printf"-style API where conversion specifiers can be used as place holders to format components of a datetime. For details on the specifiers supported, see the
fmt::strtimemodule documentation.Errors and panics
While this routine itself does not error or panic, using the value returned may result in a panic if formatting fails. See the documentation on
fmt::strtime::Displayfor more information.To format in a way that surfaces errors without panicking, use either
fmt::strtime::formatorfmt::strtime::BrokenDownTime::format.Example
This example shows how to format a civil time in a 12 hour clock with no padding for the hour:
use time; let t = time; let string = t.strftime.to_string; assert_eq!;Note that one can round a
Timebefore formatting. For example, to round to the nearest minute:use ; let t = time; let string = t.round?.strftime.to_string; assert_eq!; # Ok::
impl Time
fn new(hour: i8, minute: i8, second: i8, subsec_nanosecond: i32) -> Result<Time, Error>Creates a new
Timevalue from its component hour, minute, second and fractional subsecond (up to nanosecond precision) values.To set the component values of a time after creating it, use
TimeWithviaTime::withto build a newTimefrom the fields of an existing time.Errors
This returns an error unless all of the following conditions are true:
0 <= hour <= 230 <= minute <= 590 <= second <= 590 <= subsec_nanosecond <= 999,999,999
Example
This shows an example of a valid time:
use Time; let t = new.unwrap; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;This shows an example of an invalid time:
use Time; assert!;const fn constant(hour: i8, minute: i8, second: i8, subsec_nanosecond: i32) -> TimeCreates a new
Timevalue in aconstcontext.Panics
This panics if the given values do not correspond to a valid
Time. All of the following conditions must be true:0 <= hour <= 230 <= minute <= 590 <= second <= 590 <= subsec_nanosecond <= 999,999,999
Similarly, when used in a const context, invalid parameters will prevent your Rust program from compiling.
Example
This shows an example of a valid time in a
constcontext:use Time; const BEDTIME: Time = constant; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;const fn midnight() -> TimeReturns the first moment of time in a day.
Specifically, this has the
hour,minute,second,millisecond,microsecondandnanosecondfields all set to0.Example
use Time; let t = midnight; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;fn with(self: Self) -> TimeWithCreate a builder for constructing a
Timefrom the fields of this time.See the methods on
TimeWithfor the different ways one can set the fields of a newTime.Example
Unlike
Date, aTimeis valid for all possible valid values of its fields. That is, there is no way for two valid field values to combine into an invalidTime. So, forTime, this builder does have as much of a benefit versus an API design with methods likeTime::with_hourandTime::with_minute. Nevertheless, this builder permits settings multiple fields at the same time and performing only one validity check. Moreover, this provides a consistent API with other date and time types in this crate.use time; let t1 = time; let t2 = t1.with.hour.minute.millisecond.build?; assert_eq!; # Ok::fn hour(self: Self) -> i8Returns the "hour" component of this time.
The value returned is guaranteed to be in the range
0..=23.Example
use time; let t = time; assert_eq!;fn minute(self: Self) -> i8Returns the "minute" component of this time.
The value returned is guaranteed to be in the range
0..=59.Example
use time; let t = time; assert_eq!;fn second(self: Self) -> i8Returns the "second" component of this time.
The value returned is guaranteed to be in the range
0..=59.Example
use time; let t = time; assert_eq!;fn millisecond(self: Self) -> i16Returns the "millisecond" component of this time.
The value returned is guaranteed to be in the range
0..=999.Example
use time; let t = time; assert_eq!;fn microsecond(self: Self) -> i16Returns the "microsecond" component of this time.
The value returned is guaranteed to be in the range
0..=999.Example
use time; let t = time; assert_eq!;fn nanosecond(self: Self) -> i16Returns the "nanosecond" component of this time.
The value returned is guaranteed to be in the range
0..=999.Example
use time; let t = time; assert_eq!;fn subsec_nanosecond(self: Self) -> i32Returns the fractional nanosecond for this
Timevalue.If you want to set this value on
Time, then useTimeWith::subsec_nanosecondviaTime::with.The value returned is guaranteed to be in the range
0..=999_999_999.Example
This shows the relationship between constructing a
Timevalue with routines likewith().millisecond()and accessing the entire fractional part as a nanosecond:use time; let t = time.with.millisecond.build?; assert_eq!; # Ok::Example: nanoseconds from a timestamp
This shows how the fractional nanosecond part of a
Timevalue manifests from a specific timestamp.use ; // 1,234 nanoseconds after the Unix epoch. let zdt = new?.in_tz?; let time = zdt.datetime.time; assert_eq!; // 1,234 nanoseconds before the Unix epoch. let zdt = new?.in_tz?; let time = zdt.datetime.time; // The nanosecond is equal to `1_000_000_000 - 1_234`. assert_eq!; // Looking at the other components of the time value might help. assert_eq!; assert_eq!; assert_eq!; # Ok::const fn to_datetime(self: Self, date: Date) -> DateTimeGiven a
Date, this constructs aDateTimevalue with its time component equal to this time.This is a convenience function for
DateTime::from_parts.Example
use ; let d = date; let t = time; assert_eq!;const fn on(self: Self, year: i16, month: i8, day: i8) -> DateTimeA convenience function for constructing a
DateTimefrom this time on the date given by its components.Example
use time; assert_eq!;One can also flip the order by making use of [
Date::at]:use date; assert_eq!;fn wrapping_add<A: Into<TimeArithmetic>>(self: Self, duration: A) -> TimeAdd the given span to this time and wrap around on overflow.
This operation accepts three different duration types:
Span,SignedDurationorstd::time::Duration. This is achieved viaFromtrait implementations for theTimeArithmetictype.Properties
Given times
t1andt2, and a spans, witht2 = t1 + s, it follows then thatt1 = t2 - sfor all values oft1andsthat sum tot2.In short, subtracting the given span from the sum returned by this function is guaranteed to result in precisely the original time.
Example: available via addition operator
This routine can be used via the
+operator.use ; let t = time; assert_eq!;Example: add nanoseconds to a
Timeuse ; let t = time; assert_eq!;Example: add span with multiple units
use ; let t = time; assert_eq!;Example: adding an empty span is a no-op
use ; let t = time; assert_eq!;Example: addition wraps on overflow
use ; let t = time; assert_eq!; assert_eq!; assert_eq!;Similarly, if there are any non-zero units greater than hours in the given span, then they also result in wrapping behavior (i.e., they are ignored):
use ; // doesn't matter what our time value is in this example let t = time; assert_eq!;fn wrapping_sub<A: Into<TimeArithmetic>>(self: Self, duration: A) -> TimeThis routine is identical to
Time::wrapping_addwith the duration negated.Example
use ; let t = time; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;fn checked_add<A: Into<TimeArithmetic>>(self: Self, duration: A) -> Result<Time, Error>Add the given span to this time and return an error if the result would otherwise overflow.
This operation accepts three different duration types:
Span,SignedDurationorstd::time::Duration. This is achieved viaFromtrait implementations for theTimeArithmetictype.Properties
Given a time
t1and a spans, and assumingt2 = t1 + sexists, it follows then thatt1 = t2 - sfor all values oft1andsthat sum to a validt2.In short, subtracting the given span from the sum returned by this function is guaranteed to result in precisely the original time.
Errors
If the sum would overflow the minimum or maximum timestamp values, then an error is returned.
If the given span has any non-zero units greater than hours, then an error is returned.
Example: add nanoseconds to a
Timeuse ; let t = time; assert_eq!; # Ok::Example: add span with multiple units
use ; let t = time; assert_eq!; # Ok::Example: adding an empty span is a no-op
use ; let t = time; assert_eq!; # Ok::Example: error on overflow
use ; // okay let t = time; assert_eq!; // not okay let t = time; assert!; # Ok::Similarly, if there are any non-zero units greater than hours in the given span, then they also result in overflow (and thus an error):
use ; // doesn't matter what our time value is in this example let t = time; assert!;Example: adding absolute durations
This shows how to add signed and unsigned absolute durations to a
Time. As with adding aSpan, any overflow that occurs results in an error.use Duration; use ; let t = time; let dur = from_mins; assert_eq!; assert_eq!; let dur = new; assert_eq!; # Ok::fn checked_sub<A: Into<TimeArithmetic>>(self: Self, duration: A) -> Result<Time, Error>This routine is identical to
Time::checked_addwith the duration negated.Errors
This has the same error conditions as
Time::checked_add.Example
use Duration; use ; let t = time; assert_eq!; assert_eq!; assert_eq!; # Ok::fn saturating_add<A: Into<TimeArithmetic>>(self: Self, duration: A) -> TimeThis routine is identical to
Time::checked_add, except the result saturates on overflow. That is, instead of overflow, eitherTime::MINorTime::MAXis returned.Example
use ; // no saturation let t = time; assert_eq!; // saturates let t = time; assert_eq!; assert_eq!; assert_eq!; assert_eq!; # Ok::Similarly, if there are any non-zero units greater than hours in the given span, then they also result in overflow (and thus saturation):
use ; // doesn't matter what our time value is in this example let t = time; assert_eq!;fn saturating_sub<A: Into<TimeArithmetic>>(self: Self, duration: A) -> TimeThis routine is identical to
Time::saturating_addwith the duration negated.Example
use ; // no saturation let t = time; assert_eq!; // saturates let t = time; assert_eq!; assert_eq!; assert_eq!; assert_eq!; # Ok::fn until<A: Into<TimeDifference>>(self: Self, other: A) -> Result<Span, Error>Returns a span representing the elapsed time from this time until the given
othertime.When
otheris earlier than this time, the span returned will be negative.Depending on the input provided, the span returned is rounded. It may also be balanced down to smaller units than the default. By default, the span returned is balanced such that the biggest possible unit is hours.
This operation is configured by providing a
TimeDifferencevalue. Since this routine accepts anything that implementsInto<TimeDifference>, once can pass aTimedirectly. One can also pass a(Unit, Time), whereUnitis treated asTimeDifference::largest.Properties
As long as no rounding is requested, it is guaranteed that adding the span returned to the
othertime will always equal this time.Errors
An error can occur if
TimeDifferenceis misconfigured. For example, if the smallest unit provided is bigger than the largest unit, or if the largest unit is bigger thanUnit::Hour.It is guaranteed that if one provides a time with the default
TimeDifferenceconfiguration, then this routine will never fail.Examples
use ; let t1 = time; let t2 = time; assert_eq!; // Flipping the dates is fine, but you'll get a negative span. assert_eq!; # Ok::Example: using smaller units
This example shows how to contract the span returned to smaller units. This makes use of a
From<(Unit, Time)> for TimeDifferencetrait implementation.use ; let t1 = time; let t2 = time; // The default limits spans to using "hours" as the biggest unit. let span = t1.until?; assert_eq!; // But we can ask for smaller units, like capping the biggest unit // to minutes instead of hours. let span = t1.until?; assert_eq!; # Ok::fn since<A: Into<TimeDifference>>(self: Self, other: A) -> Result<Span, Error>This routine is identical to
Time::until, but the order of the parameters is flipped.Errors
This has the same error conditions as
Time::until.Example
This routine can be used via the
-operator. Since the default configuration is used and because aSpancan represent the difference between any two possible times, it will never panic.use ; let earlier = time; let later = time; assert_eq!;fn duration_until(self: Self, other: Time) -> SignedDurationReturns an absolute duration representing the elapsed time from this time until the given
othertime.When
otheroccurs before this time, then the duration returned will be negative.Unlike
Time::until, this returns a duration corresponding to a 96-bit integer of nanoseconds between two times. In this case of computing durations between civil times where all days are assumed to be 24 hours long, the duration returned will always be less than 24 hours.Fallibility
This routine never panics or returns an error. Since there are no configuration options that can be incorrectly provided, no error is possible when calling this routine. In contrast,
Time::untilcan return an error in some cases due to misconfiguration. But like this routine,Time::untilnever panics or returns an error in its default configuration.When should I use this versus
Time::until?See the type documentation for
SignedDurationfor the section on when one should useSpanand when one should useSignedDuration. In short, useSpan(and thereforeTime::until) unless you have a specific reason to do otherwise.Example
use ; let t1 = time; let t2 = time; assert_eq!; // Flipping the time is fine, but you'll get a negative duration. assert_eq!;Example: difference with
Time::untilSince the difference between two civil times is always expressed in units of hours or smaller, and units of hours or smaller are always uniform, there is no "expressive" difference between this routine and
Time::until. The only difference is that this routine returns aSignedDurationandTime::untilreturns aSpan. Moreover, since the difference is always less than 24 hours, the return values can always be infallibly and losslessly converted between each other:use ; let t1 = time; let t2 = time; let dur = t1.duration_until; // Guaranteed to never fail because the duration // between two civil times never exceeds the limits // of a `Span`. let span = try_from.unwrap; assert_eq!; // Guaranteed to succeed and always return the original // duration because the units are always hours or smaller, // and thus uniform. This means a relative datetime is // never required to do this conversion. let dur = try_from.unwrap; assert_eq!;This conversion guarantee also applies to
Time::untilsince it always returns a balanced span. That is, it never returns spans like1 second 1000 milliseconds. (Those cannot be losslessly converted to aSignedDurationsince aSignedDurationis only represented as a single 96-bit integer of nanoseconds.)Example: getting an unsigned duration
If you're looking to find the duration between two times as a
std::time::Duration, you'll need to use this method to get aSignedDurationand then convert it to astd::time::Duration:use Duration; use ; let t1 = time; let t2 = time; let dur = try_from?;; assert_eq!; // Note that unsigned durations cannot represent all // possible differences! If the duration would be negative, // then the conversion fails: assert!; # Ok::fn duration_since(self: Self, other: Time) -> SignedDurationThis routine is identical to
Time::duration_until, but the order of the parameters is flipped.Example
use ; let earlier = time; let later = time; assert_eq!;fn round<R: Into<TimeRound>>(self: Self, options: R) -> Result<Time, Error>Rounds this time according to the
TimeRoundconfiguration given.The principal option is
TimeRound::smallest, which allows one to configure the smallest units in the returned time. Rounding is what determines whether that unit should keep its current value or whether it should be incremented. Moreover, the amount it should be incremented can be configured viaTimeRound::increment. Finally, the rounding strategy itself can be configured viaTimeRound::mode.Note that this routine is generic and accepts anything that implements
Into<TimeRound>. Some notable implementations are:From<Unit> for Round, which will automatically create aTimeRound::new().smallest(unit)from the unit provided.From<(Unit, i64)> for Round, which will automatically create aTimeRound::new().smallest(unit).increment(number)from the unit and increment provided.
Errors
This returns an error if the smallest unit configured on the given
TimeRoundis bigger than hours.The rounding increment must divide evenly into the next highest unit after the smallest unit configured (and must not be equivalent to it). For example, if the smallest unit is
Unit::Nanosecond, then some of the valid values for the rounding increment are1,2,4,5,100and500. Namely, any integer that divides evenly into1,000nanoseconds since there are1,000nanoseconds in the next highest unit (microseconds).This can never fail because of overflow for any input. The only possible errors are "configuration" errors.
Example
This is a basic example that demonstrates rounding a datetime to the nearest second. This also demonstrates calling this method with the smallest unit directly, instead of constructing a
TimeRoundmanually.use ; let t = time; assert_eq!; let t = time; assert_eq!; # Ok::Example: changing the rounding mode
The default rounding mode is
RoundMode::HalfExpand, which breaks ties by rounding away from zero. But other modes likeRoundMode::Trunccan be used too:use ; let t = time; assert_eq!; // The default will round up to the next second for any fraction // greater than or equal to 0.5. But truncation will always round // toward zero. assert_eq!; # Ok::Example: rounding to the nearest 5 minute increment
use ; // rounds down let t = time; assert_eq!; // rounds up let t = time; assert_eq!; # Ok::Example: rounding wraps around on overflow
This example demonstrates that it's possible for this operation to overflow, and as a result, have the time wrap around.
use ; let t = MAX; assert_eq!; # Ok::fn series(self: Self, period: Span) -> TimeSeriesReturn an iterator of periodic times determined by the given span.
The given span may be negative, in which case, the iterator will move backwards through time. The iterator won't stop until either the span itself overflows, or it would otherwise exceed the minimum or maximum
Timevalue.Example: visiting every third hour
This shows how to visit each third hour of a 24 hour time interval:
use ; let start = MIN; let mut every_third_hour = vec!; for t in start.series assert_eq!;Or go backwards every 6.5 hours:
use ; let start = time; let times: = start.series.collect; assert_eq!;
impl Add for Time
fn add(self: Self, rhs: SignedDuration) -> Time
impl Add for Time
fn add(self: Self, rhs: UnsignedDuration) -> Time
impl Add for Time
fn add(self: Self, rhs: Span) -> Time
impl AddAssign for Time
fn add_assign(self: &mut Self, rhs: SignedDuration)
impl AddAssign for Time
fn add_assign(self: &mut Self, rhs: UnsignedDuration)
impl AddAssign for Time
fn add_assign(self: &mut Self, rhs: Span)
impl Clone for Time
fn clone(self: &Self) -> Time
impl Copy for Time
impl Debug for Time
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Default for Time
fn default() -> Time
impl Display for Time
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Time
impl Freeze for Time
impl From for Time
fn from(dt: DateTime) -> Time
impl From for Time
fn from(zdt: Zoned) -> Time
impl FromStr for Time
fn from_str(string: &str) -> Result<Time, Error>
impl Hash for Time
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl Ord for Time
fn cmp(self: &Self, other: &Time) -> Ordering
impl PartialEq for Time
fn eq(self: &Self, other: &Time) -> bool
impl PartialOrd for Time
fn partial_cmp(self: &Self, other: &Time) -> Option<Ordering>
impl RefUnwindSafe for Time
impl Send for Time
impl Serialize for Time
fn serialize<S: serde::Serializer>(self: &Self, serializer: S) -> Result<<S as >::Ok, <S as >::Error>
impl StructuralPartialEq for Time
impl Sub for Time
fn sub(self: Self, rhs: SignedDuration) -> Time
impl Sub for Time
fn sub(self: Self, rhs: UnsignedDuration) -> Time
impl Sub for Time
fn sub(self: Self, rhs: Span) -> Time
impl Sub for Time
fn sub(self: Self, rhs: Time) -> Span
impl SubAssign for Time
fn sub_assign(self: &mut Self, rhs: SignedDuration)
impl SubAssign for Time
fn sub_assign(self: &mut Self, rhs: UnsignedDuration)
impl SubAssign for Time
fn sub_assign(self: &mut Self, rhs: Span)
impl Sync for Time
impl Unpin for Time
impl UnsafeUnpin for Time
impl UnwindSafe for Time
impl<'a> From for Time
fn from(zdt: &'a Zoned) -> Time
impl<'de> Deserialize for Time
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Time, <D as >::Error>
impl<T> Any for Time
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Time
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Time
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Time
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> DeserializeOwned for Time
impl<T> From for Time
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Time
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> ToString for Time
fn to_string(self: &Self) -> String
impl<T, U> Into for Time
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Time
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Time
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>