Ejemplo n.º 1
0
        /// <summary>
        /// Converts this time value to a <see cref="TimeSpan"/> instance.
        /// </summary>
        /// <value>Equivalent <see cref="TimeSpan"/> value</value>
        /// <exception cref="ValueTruncationException">If a truncation occurs during conversion</exception>
        public TimeSpan ToTimeSpan()
        {
            TemporalHelpers.AssertNoTruncation(this, nameof(TimeSpan));

            return(new TimeSpan(0, Hour, Minute, Second).Add(
                       TimeSpan.FromTicks(TemporalHelpers.ExtractTicksFromNanosecond(Nanosecond))));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts this date value to a <see cref="DateTime"/> instance.
        /// </summary>
        /// <value>Equivalent <see cref="DateTime"/> value</value>
        /// <exception cref="ValueOverflowException">If the value cannot be represented with DateTime</exception>
        /// <exception cref="ValueTruncationException">If a truncation occurs during conversion</exception>
        /// <returns>A <see cref="DateTime"/> instance.</returns>
        public DateTime ToDateTime()
        {
            TemporalHelpers.AssertNoTruncation(this, nameof(System.DateTime));
            TemporalHelpers.AssertNoOverflow(this, nameof(System.DateTime));

            return(new DateTime(Year, Month, Day, Hour, Minute, Second).AddTicks(
                       TemporalHelpers.ExtractTicksFromNanosecond(Nanosecond)));
        }