本文整理汇总了C#中IDateTime类的典型用法代码示例。如果您正苦于以下问题:C# IDateTime类的具体用法?C# IDateTime怎么用?C# IDateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDateTime类属于命名空间,在下文中一共展示了IDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EvaluateToPreviousOccurrence
public void EvaluateToPreviousOccurrence(IDateTime completedDate, IDateTime currDt)
{
IDateTime beginningDate = completedDate.Copy<IDateTime>();
if (Todo.RecurrenceRules != null)
{
foreach (IRecurrencePattern rrule in Todo.RecurrenceRules)
DetermineStartingRecurrence(rrule, ref beginningDate);
}
if (Todo.RecurrenceDates != null)
{
foreach (IPeriodList rdate in Todo.RecurrenceDates)
DetermineStartingRecurrence(rdate, ref beginningDate);
}
if (Todo.ExceptionRules != null)
{
foreach (IRecurrencePattern exrule in Todo.ExceptionRules)
DetermineStartingRecurrence(exrule, ref beginningDate);
}
if (Todo.ExceptionDates != null)
{
foreach (IPeriodList exdate in Todo.ExceptionDates)
DetermineStartingRecurrence(exdate, ref beginningDate);
}
Evaluate(Todo.Start, DateUtil.GetSimpleDateTimeData(beginningDate), DateUtil.GetSimpleDateTimeData(currDt).AddTicks(1), true);
}
示例2: PurchaseController
/// <summary>
/// Initialize purchase controller
/// </summary>
/// <param name="courseCtrl">Course API</param>
/// <param name="myCourseCtrl">MyCourse API</param>
/// <param name="userProfileRepo">User profile repository</param>
/// <param name="classRoomRepo">Class room repository</param>
/// <param name="classCalendarRepo">Class calendar repository</param>
/// <param name="lessonCatalogRepo">Lesson catalog repository</param>
/// <param name="userActivityRepo">User activity repository</param>
/// <param name="paymentRepo">Payment repository</param>
public PurchaseController(CourseController courseCtrl,
MyCourseController myCourseCtrl,
IUserProfileRepository userProfileRepo,
IClassRoomRepository classRoomRepo,
IClassCalendarRepository classCalendarRepo,
ILessonCatalogRepository lessonCatalogRepo,
IUserActivityRepository userActivityRepo,
IPaymentRepository paymentRepo,
IOptions<AppConfigOptions> appConfig,
IOptions<ErrorMessageOptions> errorMsgs,
ILoggerFactory loggerFactory,
IPayment payment,
IDateTime dateTime)
{
_courseCtrl = courseCtrl;
_myCourseCtrl = myCourseCtrl;
_userprofileRepo = userProfileRepo;
_classRoomRepo = classRoomRepo;
_classCalendarRepo = classCalendarRepo;
_lessonCatalogRepo = lessonCatalogRepo;
_userActivityRepo = userActivityRepo;
_paymentRepo = paymentRepo;
_dateTime = dateTime;
_appConfig = appConfig.Value;
_errorMsgs = errorMsgs.Value;
_logger = loggerFactory.CreateLogger<PurchaseController>();
_payment = payment;
}
示例3: EvaluateRRule
/// <summary>
/// Evaulates the RRule component, and adds each specified Period
/// to the <see cref="Periods"/> collection.
/// </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>
virtual protected void EvaluateRRule(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
{
// Handle RRULEs
if (Recurrable.RecurrenceRules != null &&
Recurrable.RecurrenceRules.Count > 0)
{
foreach (IRecurrencePattern rrule in Recurrable.RecurrenceRules)
{
IEvaluator evaluator = rrule.GetService(typeof(IEvaluator)) as IEvaluator;
if (evaluator != null)
{
IList<IPeriod> periods = evaluator.Evaluate(referenceDate, periodStart, periodEnd, includeReferenceDateInResults);
foreach (IPeriod p in periods)
{
if (!Periods.Contains(p))
Periods.Add(p);
}
}
}
}
else if (includeReferenceDateInResults)
{
// If no RRULEs were found, then we still need to add
// the initial reference date to the results.
IPeriod p = new Period(referenceDate.Copy<IDateTime>());
if (!Periods.Contains(p))
Periods.Add(p);
}
}
示例4: QuestionVM
public QuestionVM(
IDateTime dateTime,
IDictionaryEntryPicker dictionaryEntryPicker)
{
_dateTime = dateTime;
_dictionaryEntryPicker = dictionaryEntryPicker;
}
示例5: Evaluate
public override IList<IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
{
Dictionary<IPeriod , bool> periodLookup = new Dictionary<IPeriod, bool>();
List<IPeriod> periods = new List<IPeriod>();
if (includeReferenceDateInResults)
{
IPeriod p = new Period(referenceDate);
if (!periodLookup.ContainsKey(p))
{
periodLookup.Add(p , true);
periods.Add(p);
}
}
if (periodEnd < periodStart)
return periods;
foreach (IPeriod p in m_PeriodList)
{
if (!periodLookup.ContainsKey(p))
{
periodLookup.Add(p, true);
periods.Add(p);
}
}
return periods;
}
示例6: MatchTimeZone
public static IDateTime MatchTimeZone(IDateTime dt1, IDateTime dt2)
{
Debug.Assert(dt1 != null && dt2 != null);
// Associate the date/time with the first.
IDateTime copy = dt2.Copy<IDateTime>();
copy.AssociateWith(dt1);
// If the dt1 time does not occur in the same time zone as the
// dt2 time, then let's convert it so they can be used in the
// same context (i.e. evaluation).
if (dt1.TZID != null)
{
if (!string.Equals(dt1.TZID, copy.TZID))
return (dt1.TimeZoneObservance != null) ? copy.ToTimeZone(dt1.TimeZoneObservance.Value) : copy.ToTimeZone(dt1.TZID);
else return copy;
}
else if (dt1.IsUniversalTime)
{
// The first date/time is in UTC time, convert!
return new iCalDateTime(copy.UTC);
}
else
{
// The first date/time is in local time, convert!
return new iCalDateTime(copy.Local);
}
}
示例7: EventOccurrenceTest
private void EventOccurrenceTest(
IICalendar iCal,
IDateTime fromDate,
IDateTime toDate,
IDateTime[] dateTimes,
string[] timeZones,
int eventIndex
)
{
IEvent evt = iCal.Events[eventIndex];
fromDate.AssociatedObject = iCal;
toDate.AssociatedObject = iCal;
IList<Occurrence> occurrences = evt.GetOccurrences(
fromDate,
toDate);
Assert.AreEqual(
dateTimes.Length,
occurrences.Count,
"There should be exactly " + dateTimes.Length + " occurrences; there were " + occurrences.Count);
for (int i = 0; i < dateTimes.Length; i++)
{
// Associate each incoming date/time with the calendar.
dateTimes[i].AssociatedObject = iCal;
IDateTime dt = dateTimes[i];
Assert.AreEqual(dt, occurrences[i].Period.StartTime, "Event should occur on " + dt);
if (timeZones != null)
Assert.AreEqual(timeZones[i], dt.TimeZoneName, "Event " + dt + " should occur in the " + timeZones[i] + " timezone");
}
}
示例8: LessonController
/// <summary>
/// Initialize lesson controller
/// </summary>
/// <param name="classCalendarRepo">Class calendar repository</param>
/// <param name="userprofileRepo">UserProfile repository</param>
/// <param name="classRoomRepo">Class room repository</param>
/// <param name="likeLessonRepo">Like lesson repository</param>
/// <param name="lessonCatalogRepo">Lesson catalog repository</param>
/// <param name="commentRepo">Comment repository</param>
/// <param name="friendRequestRepo">Friend request repository</param>
/// <param name="userActivityRepo">User activity repository</param>
/// <param name="notificationCtrl">Notificaotion API</param>
/// <param name="config">App configuration option</param>
public LessonController(IClassCalendarRepository classCalendarRepo,
IUserProfileRepository userprofileRepo,
IClassRoomRepository classRoomRepo,
ILikeLessonRepository likeLessonRepo,
ILessonCatalogRepository lessonCatalogRepo,
ICommentRepository commentRepo,
IFriendRequestRepository friendRequestRepo,
IUserActivityRepository userActivityRepo,
NotificationController notificationCtrl,
IOptions<AppConfigOptions> options,
ILessonTestResultRepository lessonTestResultRepo,
IDateTime dateTime)
{
_classCalendarRepo = classCalendarRepo;
_userprofileRepo = userprofileRepo;
_classRoomRepo = classRoomRepo;
_likeLessonRepo = likeLessonRepo;
_lessonCatalogRepo = lessonCatalogRepo;
_commentRepo = commentRepo;
_friendRequestRepo = friendRequestRepo;
_userActivityRepo = userActivityRepo;
_notificationCtrl = notificationCtrl;
_appConfig = options.Value;
_dateTime = dateTime;
_lessonTestResultRepo = lessonTestResultRepo;
}
示例9: ProcessOccurrences
void ProcessOccurrences(IDateTime referenceDate)
{
//// Sort the occurrences by start time
//m_Occurrences.Sort(
// delegate(Occurrence o1, Occurrence o2)
// {
// if (o1.Period == null || o1.Period.StartTime == null)
// return -1;
// else if (o2.Period == null || o2.Period.StartTime == null)
// return 1;
// else return o1.Period.StartTime.CompareTo(o2.Period.StartTime);
// }
//);
for (int i = 0; i < m_Occurrences.Count; i++)
{
Occurrence curr = m_Occurrences.Values[i];
Occurrence? next = i < m_Occurrences.Count - 1 ? (Occurrence?)m_Occurrences.Values[i + 1] : null;
// Determine end times for our periods, overwriting previously calculated end times.
// This is important because we don't want to overcalculate our time zone information,
// but simply calculate enough to be accurate. When date/time ranges that are out of
// normal working bounds are encountered, then occurrences are processed again, and
// new end times are determined.
if (next != null && next.HasValue)
{
curr.Period.EndTime = next.Value.Period.StartTime.AddTicks(-1);
}
else
{
curr.Period.EndTime = ConvertToIDateTime(EvaluationEndBounds, referenceDate);
}
}
}
示例10: MyCourseController
/// <summary>
/// Initialize comment controller
/// </summary>
/// <param name="classCalendarRepo">Class calendar repository</param>
/// <param name="userprofileRepo">UserProfile repository</param>
/// <param name="userActivityRepo">User activity repository</param>
/// <param name="classRoomRepo">Class room repository</param>
/// <param name="studentKeyRepo">Student key repository</param>
/// <param name="lessonCatalogRepo">Lesson catalog repository</param>
/// <param name="contractRepo">Contract repository</param>
/// <param name="likeCommentRepo">Like comment repository</param>
/// <param name="likeDiscussionRepo">Like discussion repository</param>
/// <param name="likeLessonRepo">Like lesson repository</param>
/// <param name="courseCatalogRepo">Course catalog repository</param>
public MyCourseController(IClassCalendarRepository classCalendarRepo,
IUserProfileRepository userprofileRepo,
IUserActivityRepository userActivityRepo,
IClassRoomRepository classRoomRepo,
IStudentKeyRepository studentKeyRepo,
ILessonCatalogRepository lessonCatalogRepo,
ILikeLessonRepository likeLessonRepo,
ILikeCommentRepository likeCommentRepo,
ILikeDiscussionRepository likeDiscussionRepo,
IContractRepository contractRepo,
ICourseCatalogRepository courseCatalogRepo,
ILoggerFactory loggerFactory,
IDateTime dateTime)
{
_classCalendarRepo = classCalendarRepo;
_userprofileRepo = userprofileRepo;
_userActivityRepo = userActivityRepo;
_classRoomRepo = classRoomRepo;
_studentKeyRepo = studentKeyRepo;
_lessonCatalogRepo = lessonCatalogRepo;
_likeLessonRepo = likeLessonRepo;
_likeCommentRepo = likeCommentRepo;
_likeDiscussionRepo = likeDiscussionRepo;
_contractRepo = contractRepo;
_courseCatalogRepo = courseCatalogRepo;
_logger = loggerFactory.CreateLogger<MyCourseController>();
_dateTime = dateTime;
}
示例11: GetOccurrences
static public IList<Occurrence> GetOccurrences(IRecurrable recurrable, IDateTime periodStart, IDateTime periodEnd, bool includeReferenceDateInResults)
{
List<Occurrence> occurrences = new List<Occurrence>();
IEvaluator evaluator = recurrable.GetService(typeof(IEvaluator)) as IEvaluator;
if (evaluator != null)
{
// Change the time zone of periodStart/periodEnd as needed
// so they can be used during the evaluation process.
periodStart = DateUtil.MatchTimeZone(recurrable.Start, periodStart);
periodEnd = DateUtil.MatchTimeZone(recurrable.Start, periodEnd);
IList<IPeriod> periods = evaluator.Evaluate(
recurrable.Start,
DateUtil.GetSimpleDateTimeData(periodStart),
DateUtil.GetSimpleDateTimeData(periodEnd),
includeReferenceDateInResults);
foreach (IPeriod p in periods)
{
// Filter the resulting periods to only contain those
// that occur sometime between startTime and endTime.
// NOTE: fixes bug #3007244 - GetOccurences not returning long spanning all-day events
IDateTime endTime = p.EndTime ?? p.StartTime;
if (endTime.GreaterThan(periodStart) && p.StartTime.LessThanOrEqual(periodEnd))
occurrences.Add(new Occurrence(recurrable, p));
}
occurrences.Sort();
}
return occurrences;
}
示例12: HomeController
public HomeController(
IReviewRepository reviewRepository,
IDateTime now)
{
_reviewRepository = reviewRepository;
_now = now;
}
示例13: StartOfDay
public static IDateTime StartOfDay(IDateTime dt)
{
return dt.
AddHours(-dt.Hour).
AddMinutes(-dt.Minute).
AddSeconds(-dt.Second);
}
示例14: StartTaskWorkflowProcessor
public StartTaskWorkflowProcessor(ITaskByIdQueryProcessor taskByIdQueryProcessor,
IUpdateTaskStatusQueryProcessor updateTaskStatusQueryProcessor, IAutoMapper autoMapper,IDateTime dateTime)
{
_taskByIdQueryProcessor = taskByIdQueryProcessor;
_updateTaskStatusQueryProcessor = updateTaskStatusQueryProcessor;
_autoMapper = autoMapper;
_dateTime = dateTime;
}
示例15: GetOccurrences
static public IList<Occurrence> GetOccurrences(IRecurrable recurrable, IDateTime dt, bool includeReferenceDateInResults)
{
return GetOccurrences(
recurrable,
new iCalDateTime(dt.Local.Date),
new iCalDateTime(dt.Local.Date.AddDays(1).AddSeconds(-1)),
includeReferenceDateInResults);
}