当前位置: 首页>>代码示例>>C#>>正文


C# Date_Time.Copy方法代码示例

本文整理汇总了C#中DDay.iCal.DataTypes.Date_Time.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# Date_Time.Copy方法的具体用法?C# Date_Time.Copy怎么用?C# Date_Time.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DDay.iCal.DataTypes.Date_Time的用法示例。


在下文中一共展示了Date_Time.Copy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Period

 public Period(Date_Time start, TimeSpan duration)
     : this()
 {
     StartTime = start.Copy();
     Duration = new Duration(duration);            
     EndTime = start + duration;
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:7,代码来源:Period.cs

示例2: Date_TimeUTCSerializer

        public Date_TimeUTCSerializer(Date_Time dt)
            : base(dt)
        {
            // Make a copy of the Date_Time object, so we don't alter
            // the original
            DateTime = dt.Copy();

            // Set the Date_Time object to UTC time
            DateTime.SetKind(DateTimeKind.Utc);            
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:10,代码来源:Date_TimeUTCSerializer.cs

示例3: Period

 public Period(Date_Time start, TimeSpan duration)
     : this()
 {
     StartTime = start.Copy();
     if (duration != TimeSpan.MinValue)
     {
         Duration = new Duration(duration);
         EndTime = start + duration;
     }            
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:10,代码来源:Period.cs

示例4: Date_TimeUTCSerializer

        public Date_TimeUTCSerializer(Date_Time dt)
            : base(dt)
        {
            // Make a copy of the Date_Time object, so we don't alter
            // the original
            DateTime = dt.Copy();

            // Set the Date_Time object to UTC time
            DateTime = DateTime.UTC;

            // Ensure time is serialized
            DateTime.HasTime = true;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:13,代码来源:Date_TimeUTCSerializer.cs

示例5: Date_TimeUTCSerializer

        public Date_TimeUTCSerializer(Date_Time dt)
            : base(dt)
        {
            // Make a copy of the Date_Time object, so we don't alter
            // the original
            DateTime = dt.Copy();

            // Set the Date_Time object to UTC time
            DateTime = DateTime.UTC;

            // FIXME: this is the old way we did it; remove when verified
            //DateTime.SetKind(DateTimeKind.Utc);            
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:13,代码来源:Date_TimeUTCSerializer.cs

示例6: DateDiff

        public static long DateDiff(Recur.FrequencyType frequency, Date_Time dt1, Date_Time dt2, DayOfWeek firstDayOfWeek) 
        {
            if (frequency == Recur.FrequencyType.YEARLY) 
                return dt2.Year - dt1.Year;

            if (frequency == Recur.FrequencyType.MONTHLY)
                return (dt2.Month - dt1.Month) + (12 * (dt2.Year - dt1.Year));

            if (frequency == Recur.FrequencyType.WEEKLY)
            {
                // Get the week of year of the time frame we want to calculate
                int firstEvalWeek = _Calendar.GetWeekOfYear(dt2.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, firstDayOfWeek);

                // Count backwards in years, calculating how many weeks' difference we have between
                // first and second dates
                Date_Time evalDate = dt2.Copy();
                while (evalDate.Year > dt1.Year)
                {
                    firstEvalWeek += _Calendar.GetWeekOfYear(new DateTime(evalDate.Year - 1, 12, 31), System.Globalization.CalendarWeekRule.FirstFourDayWeek, firstDayOfWeek);
                    evalDate = evalDate.AddYears(-1);
                }

                // Determine the difference, in weeks, between the start date and the evaluation period.
                int startWeek = _Calendar.GetWeekOfYear(dt1.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, firstDayOfWeek);
                return firstEvalWeek - startWeek;                
            }
 
            TimeSpan ts = dt2 - dt1;

            if (frequency == Recur.FrequencyType.DAILY) 
                return Round(ts.TotalDays);

            if (frequency == Recur.FrequencyType.HOURLY) 
                return Round(ts.TotalHours);

            if (frequency == Recur.FrequencyType.MINUTELY) 
                return Round(ts.TotalMinutes);

            if (frequency == Recur.FrequencyType.SECONDLY) 
                return Round(ts.TotalSeconds); 
 
            return 0;  
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:43,代码来源:DateUtils.cs

示例7: Evaluate

        /// <summary>
        /// Evaluates this item to determine the dates and times for which it occurs/recurs.
        /// This method only evaluates items which occur/recur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of items which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of todos, in sequence, or for a very large time span.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns></returns>
        virtual public ArrayList Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Evaluate extra time periods, without re-evaluating ones that were already evaluated
            if ((EvalStart == null && EvalEnd == null) ||
                (ToDate == EvalStart) ||
                (FromDate == EvalEnd))
            {
                EvaluateRRule(FromDate, ToDate);
                EvaluateRDate(FromDate, ToDate);
                EvaluateExRule(FromDate, ToDate);
                EvaluateExDate(FromDate, ToDate);
                if (EvalStart == null || EvalStart > FromDate)
                    EvalStart = FromDate.Copy();
                if (EvalEnd == null || EvalEnd < ToDate)
                    EvalEnd = ToDate.Copy();
            }

            if (EvalStart != null && FromDate < EvalStart)
                Evaluate(FromDate, EvalStart);
            if (EvalEnd != null && ToDate > EvalEnd)
                Evaluate(EvalEnd, ToDate);

            return DateTimes;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:38,代码来源:RecurringComponent.cs

示例8: EvaluateToPreviousOccurrence

        private void EvaluateToPreviousOccurrence(Date_Time completedDate, Date_Time currDt)
        {
            Date_Time beginningDate = completedDate.Copy();
            if (RRule != null) foreach (Recur rrule in RRule) DetermineStartingRecurrence(rrule, ref beginningDate);
            if (RDate != null) foreach (RDate rdate in RDate) DetermineStartingRecurrence(rdate, ref beginningDate);
            if (ExRule != null) foreach (Recur exrule in ExRule) DetermineStartingRecurrence(exrule, ref beginningDate);
            if (ExDate != null) foreach (RDate exdate in ExDate) DetermineStartingRecurrence(exdate, ref beginningDate);

            Evaluate(beginningDate, currDt);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:10,代码来源:Todo.cs

示例9: GetOccurrences

        protected ArrayList GetOccurrences(Date_Time StartDate, Date_Time EndDate, int Count)
        {
            ArrayList DateTimes = new ArrayList();
            while (StartDate <= EndDate &&
                (Count == int.MinValue ||
                DateTimes.Count <= Count))
            {
                // Retrieve occurrences that occur on our interval period
                if (BySetPos.Count == 0 && CheckValidDate(StartDate) && !DateTimes.Contains(StartDate.Value))
                    DateTimes.Add(StartDate.Copy());

                // Retrieve "extra" occurrences that happen within our interval period
                if (Frequency > FrequencyType.SECONDLY)
                {
                    foreach (Date_Time dt in GetExtraOccurrences(StartDate, EndDate))
                    {
                        // Don't add duplicates
                        if (!DateTimes.Contains(dt))
                            DateTimes.Add(dt.Copy());
                    }
                }

                IncrementDate(StartDate);
            }            

            return DateTimes;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:27,代码来源:Recur.cs

示例10: CreateInitialize

        public override void CreateInitialize()
        {
            base.CreateInitialize();

            // Create a new UID for the component
            UID = UniqueComponent.NewUID();

            // Here, we don't simply set to DateTime.Now because DateTime.Now contains milliseconds, and
            // the iCalendar standard doesn't care at all about milliseconds.  Therefore, when comparing
            // two calendars, one generated, and one loaded from file, they may be functionally identical,
            // but be determined to be different due to millisecond differences.
            Created = new Date_Time(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            DTStamp = Created.Copy();
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:14,代码来源:UniqueComponent.cs

示例11: Evaluate

        /// <summary>
        /// Evaluates this item to determine the dates and times for which it occurs/recurs.
        /// This method only evaluates items which occur/recur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of items which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method is called for a large number
        ///     of items, in sequence, or for a very large time span.
        /// </note>
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns>
        ///     An <see cref="ArrayList"/> containing a <see cref="Date_Time"/> object for
        ///     each date/time this item occurs/recurs.
        /// </returns>
        virtual public List<Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Evaluate extra time periods, without re-evaluating ones that were already evaluated
            if ((EvalStart == null && EvalEnd == null) ||
                (ToDate == EvalStart) ||
                (FromDate == EvalEnd))
            {
                EvaluateRRule(FromDate, ToDate);
                EvaluateRDate(FromDate, ToDate);
                EvaluateExRule(FromDate, ToDate);
                EvaluateExDate(FromDate, ToDate);
                if (EvalStart == null || EvalStart > FromDate)
                    EvalStart = FromDate.Copy();
                if (EvalEnd == null || EvalEnd < ToDate)
                    EvalEnd = ToDate.Copy();
            }

            if (EvalStart != null && FromDate < EvalStart)
                Evaluate(FromDate, EvalStart);
            if (EvalEnd != null && ToDate > EvalEnd)
                Evaluate(EvalEnd, ToDate);

            Periods.Sort();

            // Ensure the Kind of time is consistent with DTStart
            foreach (Period p in Periods)
            {                
                if (p.StartTime.Kind != DTStart.Kind)
                {
                    p.StartTime.Value = new DateTime(p.StartTime.Year, p.StartTime.Month, p.StartTime.Day,
                        p.StartTime.Hour, p.StartTime.Minute, p.StartTime.Second, DTStart.Kind);
                }
            }

            // Evaluate all Alarms for this component.
            foreach (Alarm alarm in Alarms)
                alarm.Evaluate(this);

            return Periods;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:58,代码来源:RecurringComponent.cs

示例12: Evaluate

        /// <summary>
        /// Evaluates this item to determine the dates and times for which it occurs/recurs.
        /// This method only evaluates items which occur/recur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of items which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method is called for a large number
        ///     of items, in sequence, or for a very large time span.
        /// </note>
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns>
        ///     An <see cref="ArrayList"/> containing a <see cref="Date_Time"/> object for
        ///     each date/time this item occurs/recurs.
        /// </returns>
        virtual public List<Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Evaluate extra time periods, without re-evaluating ones that were already evaluated
            if ((EvalStart == null && EvalEnd == null) ||
                (ToDate == EvalStart) ||
                (FromDate == EvalEnd))
            {
                EvaluateRRule(FromDate, ToDate);
                EvaluateRDate(FromDate, ToDate);
                EvaluateExRule(FromDate, ToDate);
                EvaluateExDate(FromDate, ToDate);
                if (EvalStart == null || EvalStart > FromDate)
                    EvalStart = FromDate.Copy();
                if (EvalEnd == null || EvalEnd < ToDate)
                    EvalEnd = ToDate.Copy();
            }

            if (EvalStart != null && FromDate < EvalStart)
                Evaluate(FromDate, EvalStart);
            if (EvalEnd != null && ToDate > EvalEnd)
                Evaluate(EvalEnd, ToDate);

            Periods.Sort();

            // Evaluate all Alarms for this component.
            foreach (Alarm alarm in Alarms)
                alarm.Evaluate(this);

            return Periods;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:48,代码来源:RecurringComponent.cs

示例13: Evaluate

        public List<Date_Time> Evaluate(Date_Time StartDate, Date_Time FromDate, Date_Time ToDate)
        {
            List<Date_Time> DateTimes = new List<Date_Time>();
            DateTimes.AddRange(StaticOccurrences);

            // Create a temporary recurrence for populating 
            // missing information using the 'StartDate'.
            Recur r = new Recur();
            r.CopyFrom(this);

            // Enforce evaluation engine rules
            r.EnforceEvaluationRestrictions();

            // Fill in missing, necessary ByXXX values
            r.EnsureByXXXValues(StartDate);
                        
            // Get the occurrences
            foreach (Date_Time occurrence in r.GetOccurrences(StartDate, FromDate.Copy(), ToDate.Copy(), r.Count))
            {
                // NOTE:
                // Used to be DateTimes.AddRange(r.GetOccurrences(FromDate.Copy(), ToDate, r.Count))
                // By doing it this way, fixes bug #19.
                if (!DateTimes.Contains(occurrence))
                    DateTimes.Add(occurrence);
            }            

            // Limit the count of returned recurrences
            if (Count != int.MinValue &&
                DateTimes.Count > Count)
                DateTimes.RemoveRange(Count, DateTimes.Count - Count);

            // Process the UNTIL, and make sure the DateTimes
            // occur between FromDate and ToDate
            for (int i = DateTimes.Count - 1; i >= 0; i--)
            {
                Date_Time dt = (Date_Time)DateTimes[i];
                if (dt > ToDate ||
                    dt < FromDate)
                    DateTimes.RemoveAt(i);
            }

            // Assign missing values
            foreach (Date_Time dt in DateTimes)
                dt.MergeWith(StartDate);

            // Ensure that DateTimes have an assigned time if they occur less than daily
            foreach (Date_Time dt in DateTimes)
            {
                if (Frequency < FrequencyType.DAILY)
                    dt.HasTime = true;
            }
            
            return DateTimes;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:54,代码来源:Recur.cs

示例14: IncrementDate

        public void IncrementDate(ref Date_Time dt, int Interval)
        {
            Date_Time old = dt.Copy();
            switch (Frequency)
            {
                case FrequencyType.SECONDLY: dt = old.AddSeconds(Interval); break;
                case FrequencyType.MINUTELY: dt = old.AddMinutes(Interval); break;
                case FrequencyType.HOURLY: dt = old.AddHours(Interval); break;
                case FrequencyType.DAILY: dt = old.AddDays(Interval); break;
                case FrequencyType.WEEKLY:
                    // How the week increments depends on the WKST indicated (defaults to Monday)
                    // So, basically, we determine the week of year using the necessary rules,
                    // and we increment the day until the week number matches our "goal" week number.
                    // So, if the current week number is 36, and our Interval is 2, then our goal
                    // week number is 38.
                    // NOTE: fixes RRULE12 eval.
                    int current = _Calendar.GetWeekOfYear(old.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst),
                        lastLastYear = _Calendar.GetWeekOfYear(new DateTime(old.Year-1, 12, 31, 0, 0, 0, DateTimeKind.Local), System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst),
                        last = _Calendar.GetWeekOfYear(new DateTime(old.Year, 12, 31, 0, 0, 0, DateTimeKind.Local), System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst),
                        goal = current + Interval;

                    // If the goal week is greater than the last week of the year, wrap it!
                    if (goal > last)
                        goal = goal - last;
                    else if (goal <= 0)
                        goal = lastLastYear + goal;

                    int interval = Interval > 0 ? 1 : -1;
                    while (current != goal)
                    {
                        old = old.AddDays(interval);
                        current = _Calendar.GetWeekOfYear(old.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst);
                    }

                    dt = old;
                    break;
                case FrequencyType.MONTHLY: dt = old.AddDays(-old.Day + 1).AddMonths(Interval); break;
                case FrequencyType.YEARLY: dt = old.AddDays(-old.DayOfYear + 1).AddYears(Interval); break;
                default: throw new Exception("FrequencyType.NONE cannot be evaluated. Please specify a FrequencyType before evaluating the recurrence.");
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:41,代码来源:Recur.cs


注:本文中的DDay.iCal.DataTypes.Date_Time.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。