本文整理汇总了C#中ITimeCalendar类的典型用法代码示例。如果您正苦于以下问题:C# ITimeCalendar类的具体用法?C# ITimeCalendar怎么用?C# ITimeCalendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITimeCalendar类属于命名空间,在下文中一共展示了ITimeCalendar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HourTimeRange
// ----------------------------------------------------------------------
protected HourTimeRange( int startYear, int startMonth, int startDay, int startHour, int hourCount, ITimeCalendar calendar )
: base(GetPeriodOf( startYear, startMonth, startDay, startHour, hourCount ), calendar)
{
this.startHour = new DateTime( startYear, startMonth, startDay, startHour, 0, 0 );
this.hourCount = hourCount;
endHour = this.startHour.AddHours( hourCount );
}
开发者ID:jwg4,项目名称:date-difference,代码行数:8,代码来源:HourTimeRange.cs
示例2: DayTimeRange
// ----------------------------------------------------------------------
protected DayTimeRange( int startYear, int startMonth, int startDay, int dayCount, ITimeCalendar calendar )
: base(GetPeriodOf( startYear, startMonth, startDay, dayCount ), calendar)
{
this.startDay = new DateTime( startYear, startMonth, startDay );
this.dayCount = dayCount;
endDay = calendar.MapEnd( this.startDay.AddDays( dayCount ) );
}
开发者ID:jwg4,项目名称:date-difference,代码行数:8,代码来源:DayTimeRange.cs
示例3: MinuteTimeRange
// ----------------------------------------------------------------------
protected MinuteTimeRange( int startYear, int startMonth, int startDay, int startHour, int startMinute, int minuteCount, ITimeCalendar calendar )
: base(GetPeriodOf( startYear, startMonth, startDay, startHour, startMinute, minuteCount ), calendar)
{
this.startMinute = new DateTime( startYear, startMonth, startDay, startHour, startMinute, 0 );
this.minuteCount = minuteCount;
endMinute = this.startMinute.AddMinutes( minuteCount );
}
开发者ID:HoLoveSalt,项目名称:showhotel,代码行数:8,代码来源:MinuteTimeRange.cs
示例4: CalendarDateDiff
public CalendarDateDiff(ITimeCalendar timeCalendar) {
timeCalendar.ShouldNotBeNull("timeCalendar");
Guard.Assert(timeCalendar.StartOffset == TimeSpan.Zero, "Calendar의 StartOffset은 TimeSpan.Zero이어야 합니다.");
Guard.Assert(timeCalendar.EndOffset == TimeSpan.Zero, "Calendar의 StartOffset은 TimeSpan.Zero이어야 합니다.");
_calendar = timeCalendar;
}
开发者ID:debop,项目名称:NFramework,代码行数:7,代码来源:CalendarDateDiff.cs
示例5: YearTimeRange
// ----------------------------------------------------------------------
protected YearTimeRange( int startYear, int yearCount, ITimeCalendar calendar )
: base(GetPeriodOf( calendar.YearBaseMonth, startYear, yearCount ), calendar)
{
this.startYear = startYear;
this.yearCount = yearCount;
endYear = End.Year;
}
开发者ID:HoLoveSalt,项目名称:showhotel,代码行数:8,代码来源:YearTimeRange.cs
示例6: CalcTimeMoment
// ----------------------------------------------------------------------
public static DateTime CalcTimeMoment( DateTime baseMoment, TimeUnit offsetUnit, long offsetCount = 1, ITimeCalendar calendar = null )
{
switch ( offsetUnit )
{
case TimeUnit.Tick:
return baseMoment.AddTicks( offsetCount );
case TimeUnit.Millisecond:
DateTime offsetMillisecond = baseMoment.AddSeconds( offsetCount );
return TimeTrim.Millisecond( offsetMillisecond, offsetMillisecond.Millisecond );
case TimeUnit.Second:
DateTime offsetSecond = baseMoment.AddSeconds( offsetCount );
return TimeTrim.Second( offsetSecond, offsetSecond.Second );
case TimeUnit.Minute:
return new Minute(baseMoment, calendar).AddMinutes( ToInt( offsetCount ) ).Start;
case TimeUnit.Hour:
return new Hour( baseMoment, calendar ).AddHours( ToInt( offsetCount ) ).Start;
case TimeUnit.Day:
return new Day( baseMoment, calendar ).AddDays( ToInt( offsetCount ) ).Start;
case TimeUnit.Week:
return new Week( baseMoment, calendar ).AddWeeks( ToInt( offsetCount ) ).Start;
case TimeUnit.Month:
return new Month( baseMoment, calendar ).AddMonths( ToInt( offsetCount ) ).Start;
case TimeUnit.Quarter:
return new Quarter( baseMoment, calendar ).AddQuarters( ToInt( offsetCount ) ).Start;
case TimeUnit.Halfyear:
return new Halfyear( baseMoment, calendar ).AddHalfyears( ToInt( offsetCount ) ).Start;
case TimeUnit.Year:
return new Year( baseMoment, calendar ).AddYears( ToInt( offsetCount ) ).Start;
default:
throw new InvalidOperationException();
}
}
开发者ID:jwg4,项目名称:date-difference,代码行数:33,代码来源:TimeUnitCalc.cs
示例7: WeekTimeRange
// ----------------------------------------------------------------------
protected WeekTimeRange( int year, int startWeek, int weekCount, ITimeCalendar calendar )
: base(GetPeriodOf( year, startWeek, weekCount, calendar ), calendar)
{
this.year = year;
this.startWeek = startWeek;
this.weekCount = weekCount;
}
开发者ID:HoLoveSalt,项目名称:showhotel,代码行数:8,代码来源:WeekTimeRange.cs
示例8: HalfyearTimeRange
// ----------------------------------------------------------------------
protected HalfyearTimeRange( int startYear, YearHalfyear startHalfyear, int halfyearCount, ITimeCalendar calendar )
: base(GetPeriodOf( calendar.YearBaseMonth, startYear, startHalfyear, halfyearCount ), calendar)
{
this.startYear = startYear;
this.startHalfyear = startHalfyear;
this.halfyearCount = halfyearCount;
TimeTool.AddHalfyear( startYear, startHalfyear, halfyearCount - 1, out endYear, out endHalfyear );
}
开发者ID:HoLoveSalt,项目名称:showhotel,代码行数:9,代码来源:HalfyearTimeRange.cs
示例9: QuarterTimeRange
// ----------------------------------------------------------------------
protected QuarterTimeRange( int startYear, YearQuarter startQuarter, int quarterCount, ITimeCalendar calendar )
: base(GetPeriodOf( calendar.YearBaseMonth, startYear, startQuarter, quarterCount ), calendar)
{
this.startYear = startYear;
this.startQuarter = startQuarter;
this.quarterCount = quarterCount;
TimeTool.AddQuarter( startYear, startQuarter, quarterCount - 1, out endYear, out endQuarter );
}
开发者ID:jwg4,项目名称:date-difference,代码行数:9,代码来源:QuarterTimeRange.cs
示例10: MonthTimeRange
// ----------------------------------------------------------------------
protected MonthTimeRange( int startYear, YearMonth startMonth, int monthCount, ITimeCalendar calendar )
: base(GetPeriodOf( startYear, startMonth, monthCount ), calendar)
{
this.startYear = startYear;
this.startMonth = startMonth;
this.monthCount = monthCount;
TimeTool.AddMonth( startYear, startMonth, monthCount - 1, out endYear, out endMonth );
}
开发者ID:jwg4,项目名称:date-difference,代码行数:9,代码来源:MonthTimeRange.cs
示例11: HalfyearTimeRange
protected HalfyearTimeRange(int startYear, HalfyearKind startHalfyearKind, int halfyearCount, ITimeCalendar calendar)
: base(GetPeriodOf(calendar.YearBaseMonth, startYear, startHalfyearKind, halfyearCount), calendar) {
StartYear = startYear;
StartHalfyear = startHalfyearKind;
HalfyearCount = halfyearCount;
var endYearAndHalfyear = TimeTool.AddHalfyear(startHalfyearKind, startYear, halfyearCount - 1);
EndYear = endYearAndHalfyear.Year ?? StartYear;
EndHalfyear = endYearAndHalfyear.Halfyear ?? StartHalfyear;
}
开发者ID:debop,项目名称:NFramework,代码行数:11,代码来源:HalfyearTimeRange.cs
示例12: CalendarDateDiff
// ----------------------------------------------------------------------
public CalendarDateDiff( ITimeCalendar calendar )
{
if ( calendar == null )
{
throw new ArgumentNullException( "calendar" );
}
if ( calendar.StartOffset != TimeSpan.Zero )
{
throw new ArgumentOutOfRangeException( "calendar", "start offset" );
}
if ( calendar.EndOffset != TimeSpan.Zero )
{
throw new ArgumentOutOfRangeException( "calendar", "end offset" );
}
this.calendar = calendar;
}
开发者ID:jwg4,项目名称:date-difference,代码行数:17,代码来源:CalendarDateDiff.cs
示例13: CalcTimePeriod
// ----------------------------------------------------------------------
public static ITimePeriod CalcTimePeriod( DateTime baseMoment, TimeUnit periodUnit, long periodDuration = 1,
TimeUnit? offsetUnit = null, long offsetCount = 1, ITimeCalendar calendar = null)
{
if ( !offsetUnit.HasValue )
{
offsetUnit = periodUnit;
}
DateTime start = CalcTimeMoment( baseMoment, offsetUnit.Value, offsetCount, calendar );
switch ( periodUnit )
{
case TimeUnit.Tick:
return new TimeRange( start, start.AddTicks( periodDuration ) );
case TimeUnit.Millisecond:
return new TimeRange( start, start.AddMilliseconds( periodDuration ) );
case TimeUnit.Second:
return new TimeRange( start, start.AddSeconds( periodDuration ) );
case TimeUnit.Minute:
return periodDuration == 1 ? new Minute( start, calendar ) as ITimePeriod : new Minutes( start, ToInt( periodDuration ), calendar );
case TimeUnit.Hour:
return periodDuration == 1 ? new Hour( start, calendar ) as ITimePeriod : new Hours( start, ToInt( periodDuration ), calendar );
case TimeUnit.Day:
return periodDuration == 1 ? new Day( start, calendar ) as ITimePeriod : new Days( start, ToInt( periodDuration ), calendar );
case TimeUnit.Week:
return periodDuration == 1 ? new Week( start, calendar ) as ITimePeriod : new Weeks( start, ToInt( periodDuration ), calendar );
case TimeUnit.Month:
YearMonth startMonth = calendar != null ? calendar.YearBaseMonth : TimeSpec.CalendarYearStartMonth;
return periodDuration == 1 ? new Month( start, calendar ) as ITimePeriod : new Months( start, startMonth, ToInt( periodDuration ), calendar );
case TimeUnit.Quarter:
return periodDuration == 1 ? new Quarter( start, calendar ) as ITimePeriod : new Quarters( start, YearQuarter.First, ToInt( periodDuration ), calendar );
case TimeUnit.Halfyear:
return periodDuration == 1 ? new Halfyear( start, calendar ) as ITimePeriod : new Halfyears( start, YearHalfyear.First, ToInt( periodDuration ), calendar );
case TimeUnit.Year:
return periodDuration == 1 ? new Year( start, calendar ) as ITimePeriod : new Years( start, ToInt( periodDuration ), calendar );
default:
throw new InvalidOperationException();
}
}
开发者ID:jwg4,项目名称:date-difference,代码行数:38,代码来源:TimeUnitCalc.cs
示例14: GetHourRange
/// <summary>
/// <paramref name="moment"/>가 속한 시간의 기간을 반환합니다 (1시간)
/// </summary>
public static HourRange GetHourRange(this DateTime moment, ITimeCalendar timeCalendar = null) {
return new HourRange(moment, timeCalendar ?? TimeCalendar.New());
}
开发者ID:debop,项目名称:NFramework,代码行数:6,代码来源:TimeTool.Period.cs
示例15: GetDayRanges
/// <summary>
/// <paramref name="moment"/>가 속한 하루서부터 <paramref name="dayCount"/>만큼의 일자의 기간
/// </summary>
public static DayRangeCollection GetDayRanges(this DateTime moment, int dayCount, ITimeCalendar timeCalendar = null) {
return new DayRangeCollection(moment, dayCount, timeCalendar ?? TimeCalendar.New());
}
开发者ID:debop,项目名称:NFramework,代码行数:6,代码来源:TimeTool.Period.cs
示例16: GetWeekRanges
/// <summary>
/// <paramref name="moment"/>가 속한 주에서 <paramref name="weekCount"/>만큼의 주의 기간
/// </summary>
public static WeekRangeCollection GetWeekRanges(this DateTime moment, int weekCount, ITimeCalendar timeCalendar = null) {
return new WeekRangeCollection(moment, weekCount, timeCalendar ?? TimeCalendar.New());
}
开发者ID:debop,项目名称:NFramework,代码行数:6,代码来源:TimeTool.Period.cs
示例17: GetQuarterRanges
/// <summary>
/// <paramref name="moment"/>가 속한 분기부터 <paramref name="quarterCount"/> 갯수의 분기까지의 기간
/// </summary>
/// <param name="moment">기준 일자</param>
/// <param name="quarterCount">분기 수</param>
/// <param name="timeCalendar">기준 TimeCalendar</param>
public static QuarterRangeCollection GetQuarterRanges(this DateTime moment, int quarterCount, ITimeCalendar timeCalendar = null) {
return new QuarterRangeCollection(moment, quarterCount, timeCalendar ?? TimeCalendar.New());
}
开发者ID:debop,项目名称:NFramework,代码行数:9,代码来源:TimeTool.Period.cs
示例18: GetYearRanges
/// <summary>
/// <paramref name="moment"/>가 속한 년과 <paramref name="yearCount"/> 만큼의 기간
/// </summary>
public static YearRangeCollection GetYearRanges(this DateTime moment, int yearCount, ITimeCalendar timeCalendar = null) {
return new YearRangeCollection(moment, yearCount, timeCalendar ?? TimeCalendar.New());
}
开发者ID:debop,项目名称:NFramework,代码行数:6,代码来源:TimeTool.Period.cs
示例19: GetPeriodsOf
/// <summary>
/// <paramref name="moment"/>이 속하면서, <paramref name="periodKind"/>에 해당하는 <see cref="ICalendarTimeRange"/>을 구합니다.
/// </summary>
/// <param name="moment"></param>
/// <param name="periodKind"></param>
/// <param name="periodCount"></param>
/// <param name="timeCalendar"></param>
/// <returns></returns>
public static ICalendarTimeRange GetPeriodsOf(this DateTime moment, PeriodKind periodKind, int periodCount,
ITimeCalendar timeCalendar) {
if(IsDebugEnabled)
log.Debug("날짜[{0}]가 속한 기간종류[{1}]의 기간을 구합니다. periodCount=[{2}], timeCalendar=[{3}]",
moment.ToSortableString(), periodKind, periodCount, timeCalendar);
switch(periodKind) {
case PeriodKind.Year:
return GetYearRanges(moment, periodCount, timeCalendar);
case PeriodKind.Halfyear:
return GetHalfyearRanges(moment, periodCount, timeCalendar);
case PeriodKind.Quarter:
return GetQuarterRanges(moment, periodCount, timeCalendar);
case PeriodKind.Month:
return GetMonthRanges(moment, periodCount, timeCalendar);
case PeriodKind.Week:
return GetWeekRanges(moment, periodCount, timeCalendar);
case PeriodKind.Day:
return GetDayRanges(moment, periodCount, timeCalendar);
case PeriodKind.Hour:
return GetHourRanges(moment, periodCount, timeCalendar);
case PeriodKind.Minute:
return GetMinuteRanges(moment, periodCount, timeCalendar);
case PeriodKind.Second:
return new CalendarTimeRange(moment.TrimToMillisecond(), DurationUtil.Seconds(periodCount), timeCalendar);
default:
throw new NotSupportedException("지원하지 않는 TimePeriod 종류입니다. periodKind=" + periodKind);
}
}
开发者ID:debop,项目名称:NFramework,代码行数:46,代码来源:TimeTool.Period.cs
示例20: Year
// ----------------------------------------------------------------------
public Year( int year, ITimeCalendar calendar )
: base(year, 1, calendar)
{
}
开发者ID:jwg4,项目名称:date-difference,代码行数:5,代码来源:Year.cs
注:本文中的ITimeCalendar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论