Пример #1
0
        /// <summary>
        /// Converts the value of the current <see cref="Date"/> object to its equivalent string representation.
        /// </summary>
        /// <returns> A string representation of the value of the current <see cref="Date"/> object.</returns>
        public readonly override string ToString()
        {
            switch (Format)
            {
            case DateFormat.Day:
                return(Day?.ToString());

            case DateFormat.Month:
                return(Month?.ToString());

            case DateFormat.Quarter:
                return(Quarter?.ToString());

            case DateFormat.SemiAnnual:
                return(SemiAnnual?.ToString());

            case DateFormat.Tertiary:
                return(Tertiary?.ToString());

            case DateFormat.Week:
                return(Week?.ToString());

            case DateFormat.Year:
                return(Year.ToString());

            default:
                Debug.Fail($"Unknown {nameof(DateFormat)}.");
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Returns the hash code for this instance.
        /// </summary>
        /// <returns>A 32-bit signed integer hash code.</returns>
        public readonly override int GetHashCode()
        {
            switch (Format)
            {
            case DateFormat.Day:
                return(Day.GetHashCode());

            case DateFormat.Month:
                return(Month.GetHashCode());

            case DateFormat.Quarter:
                return(Quarter.GetHashCode());

            case DateFormat.SemiAnnual:
                return(SemiAnnual.GetHashCode());

            case DateFormat.Tertiary:
                return(Tertiary.GetHashCode());

            case DateFormat.Week:
                return(Week.GetHashCode());

            case DateFormat.Year:
                return(Year.GetHashCode());

            default:
                Debug.Fail($"Unknown {nameof(DateFormat)}.");
                return(0);
            }
        }
Пример #3
0
 /// <summary>
 /// Creates an instance of a <see cref="Date"/> with a format of YYYY-Tx (<see cref="DateFormat.Tertiary"/>) where x is a tertiary between 1 and 3.
 /// </summary>
 /// <param name="tertiary">A specific tertiary of a specific year.</param>
 public Date(Tertiary tertiary)
 {
     Day        = default;
     Month      = default;
     Quarter    = default;
     SemiAnnual = default;
     Tertiary   = tertiary;
     Year       = tertiary.Year;
     Week       = default;
     Format     = DateFormat.Tertiary;
 }