HasTimePart() 공개 정적인 메소드

하루중 시간 부분이 존재하면 참을 반환합니다.
public static HasTimePart ( this dateTime ) : bool
dateTime this
리턴 bool
예제 #1
0
        /// <summary>
        /// 시간 간격을 문자열로 표현합니다.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="startEdge"></param>
        /// <param name="endEdge"></param>
        /// <param name="duration"></param>
        /// <returns></returns>
        public string GetInterval(DateTime start, DateTime end, IntervalEdge startEdge, IntervalEdge endEdge, TimeSpan duration)
        {
            if (end < start)
            {
                throw new ArgumentOutOfRangeException("end");
            }

            StringBuilder sb = new StringBuilder();

            // interval start
            switch (startEdge)
            {
            case IntervalEdge.Closed:
                sb.Append("[");
                break;

            case IntervalEdge.Open:
                sb.Append(UseIsoIntervalNotation ? "]" : "(");
                break;
            }

            bool addDuration       = true;
            bool startHasTimeOfDay = TimeTool.HasTimePart(start);

            // no duration - schow start date (optionally with the time part)
            if (duration == TimeSpec.MinPeriodDuration)
            {
                sb.Append(startHasTimeOfDay ? GetDateTime(start) : GetShortDate(start));
                addDuration = false;
            }
            // within one day: show full start, end time and suration
            else if (TimeTool.IsSameDay(start, end))
            {
                sb.Append(GetDateTime(start));
                sb.Append(StartEndSeparator);
                sb.Append(GetLongTime(end));
                sb.Append(GetShortDate(start));
            }
            else
            {
                bool endHasTimeOfDay = TimeTool.HasTimePart(start);
                bool hasTimeOfDays   = startHasTimeOfDay || endHasTimeOfDay;
                if (hasTimeOfDays)
                {
                    sb.Append(GetDateTime(start));
                    sb.Append(StartEndSeparator);
                    sb.Append(GetDateTime(start));
                }
                else
                {
                    sb.Append(GetShortDate(start));
                    sb.Append(StartEndSeparator);
                    sb.Append(GetShortDate(end));
                }
            }

            // interval end
            switch (endEdge)
            {
            case IntervalEdge.Closed:
                sb.Append("]");
                break;

            case IntervalEdge.Open:
                sb.Append(UseIsoIntervalNotation ? "[" : ")");
                break;
            }

            // duration
            if (addDuration)
            {
                sb.Append(DurationSeparator);
                sb.Append(GetDuration(duration));
            }

            return(sb.ToString());
        }