예제 #1
0
        /// <summary>
        /// Gets the current local time of day only.
        /// </summary>
        /// <returns>
        /// TimeSpan object that is the current local time of day.
        /// </returns>
        public static TimeSpan GetCurrentLocalTimeOfDay(this IClock clock)
        {
            Contract.Requires(clock != null);

            var currentLocalDateTime  = clock.GetCurrentLocalDateTime();
            var currentLocalTimeOfDay = currentLocalDateTime.TimeOfDay;

            return(currentLocalTimeOfDay);
        }
예제 #2
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Extensions Methods
        /// <summary>
        /// Gets the current local date only. Time portion will be midnight.
        /// </summary>
        /// <returns>
        /// DateTime object that is the current local date.
        /// </returns>
        public static DateTime GetCurrentLocalDate(this IClock clock)
        {
            Contract.Requires(clock != null);

            var currentLocalDateTime = clock.GetCurrentLocalDateTime();
            var currentLocalDate     = currentLocalDateTime.Date;

            return(currentLocalDate);
        }
예제 #3
0
        /// <summary>
        /// Gets the current UTC date only. Time portion will be midnight.
        /// </summary>
        /// <returns>
        /// DateTime object that is the current UTC date.
        /// </returns>
        public static DateTime GetCurrentUtcDate(this IClock clock)
        {
            Contract.Requires(clock != null);

            return(clock.GetCurrentLocalDateTime().Date);
        }