Example #1
0
        /// <summary>Trims to the nearest milli-second.</summary>
        /// <param name="time">The date time</param>
        /// <param name="trim">The trim.</param>
        /// <returns>DateTime</returns>
        public DateTime Trim(DateTime time, enDateTimeTrim trim = enDateTimeTrim.Trim2Second)
        {
            switch (trim)
            {
            case enDateTimeTrim.Trim2Day:  return(time.Date);

            case enDateTimeTrim.Trim2Hour: return(Trim_Setup(time, TimeSpan.FromHours(1)));

            case enDateTimeTrim.Trim2Minute: return(Trim_Setup(time, TimeSpan.FromMinutes(1)));

            case enDateTimeTrim.Trim2Second: return(Trim_Setup(time, TimeSpan.FromSeconds(1)));

            case enDateTimeTrim.Trim2MilliSecond: return(Trim_Setup(time, TimeSpan.FromMilliseconds(1)));

            default: throw new Exception($"Argument '{nameof(trim)}' error.");
            }
        }
Example #2
0
        public DateTime Time(string fileName, enIO_FileActionTime fileTime = enIO_FileActionTime.Creation, enDateTimeTrim trim = enDateTimeTrim.Trim2Second)
        {
            DateTime result = _lamed.Types.DateTime.null_;
            var      _time  = _lamed.Types.DateTime;

            switch (fileTime)
            {
            case enIO_FileActionTime.Creation:   result = _time.Trim(File.GetCreationTime(fileName), trim); break;

            case enIO_FileActionTime.LastAccess: result = _time.Trim(File.GetLastAccessTime(fileName), trim); break;

            case enIO_FileActionTime.LastWrite: result = _time.Trim(File.GetLastWriteTime(fileName), trim); break;

            default: throw new Exception($"Argument '{nameof(fileTime)}' error.");
            }
            return(result);
        }