本文整理汇总了C#中System.Globalization.GregorianCalendar类的典型用法代码示例。如果您正苦于以下问题:C# GregorianCalendar类的具体用法?C# GregorianCalendar怎么用?C# GregorianCalendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GregorianCalendar类属于System.Globalization命名空间,在下文中一共展示了GregorianCalendar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetDaylightChanges
/// <summary>
/// Returns the daylight changes for UTC (never).
/// </summary>
public override DaylightTime GetDaylightChanges(int year)
{
// We need a start and stop time
DateTime start, end;
Calendar cal = new GregorianCalendar();
// 2007+ at this point has a slightly different start/stop
if (year >= 2007)
{
start = new DateTime(year, 4, 1, 2, 0, 0);
end = new DateTime(year, 11, 1, 2, 0, 0);
}
else
{
start = new DateTime(year, 3, 1, 2, 0, 0);
end = new DateTime(year, 12, 1, 2, 0, 0);
}
// Move forward for the start date until we have a sunday
while (cal.GetDayOfWeek(start) != DayOfWeek.Sunday)
start = cal.AddDays(start, 1);
// Move backwards from the end date to the last sunday
while (cal.GetDayOfWeek(end) != DayOfWeek.Sunday)
start = cal.AddDays(end, 1);
// Create it
return new DaylightTime(start, end,
new TimeSpan(stOffset - dtOffset, 0, 0));
}
开发者ID:DF-thangld,项目名称:web_game,代码行数:33,代码来源:TimeZoneUS.cs
示例2: WorkYear
public WorkYear(int year, WorkDayParserSettings parserSettings, int hitListLookBackInWeeks, float hoursPerDay, PNSearchViewModel pnSearch, PositionSearchViewModel positionSearch)
{
this.hitListLookBackInWeeks = hitListLookBackInWeeks;
this.pnSearch = pnSearch;
this.positionSearch = positionSearch;
this.Year = year;
this.Months = new ObservableCollection<WorkMonth>();
this.Weeks = new ObservableCollection<WorkWeek>();
var germanSpecialDays = SpecialDaysUtils.GetGermanSpecialDays(year);
var cal = new GregorianCalendar();
for (int month = 1; month <= cal.GetMonthsInYear(year); month++)
{
WorkMonth wm = new WorkMonth(year, month, germanSpecialDays, parserSettings, hoursPerDay);
this.Months.Add(wm);
foreach (var workWeek in wm.Weeks)
{
this.Weeks.Add(workWeek);
workWeek.PropertyChanged += this.workWeek_PropertyChanged;
}
}
this.ProjectHitlist = new QuickFillObservableCollection<HitlistInfo>();
this.PositionHitlist = new QuickFillObservableCollection<HitlistInfo>();
this.UpdateProjectHitlistAsync();
this.UpdatePositionHitlistAsync();
}
开发者ID:dotob,项目名称:moni,代码行数:27,代码来源:WorkYear.cs
示例3: Create
public List<List<CalendarDay>> Create(IQueryable<Episode> episodeCollection, DateTime currentDate)
{
List<List<CalendarDay>> model = this.ConstructModel();
Calendar calendar = new GregorianCalendar();
const int CalendarDays = 42;
DateTime startDate = new DateTime(currentDate.Year, currentDate.Month, 1);
startDate = startDate.Subtract(new TimeSpan((int)calendar.GetDayOfWeek(startDate) - (int)DayOfWeek.Monday, 0, 0, 0));
DateTime endDate = startDate.Add(new TimeSpan(CalendarDays, 0, 0, 0));
List<CalendarEpisode> episodes = this.GetEpisodes(episodeCollection, startDate, endDate);
int weekIndex = 0;
for (int i = 0; i < CalendarDays; i++)
{
DayOfWeek dayOfWeek = calendar.GetDayOfWeek(startDate);
this.AddEpisodes(model, episodes, startDate, weekIndex);
startDate = startDate.AddDays(1);
if (dayOfWeek == DayOfWeek.Sunday)
{
weekIndex++;
}
}
return model;
}
开发者ID:HristoKolev,项目名称:TrackTV,代码行数:34,代码来源:EpisodeCalendar.cs
示例4: PosTest1
public void PosTest1()
{
System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
System.Globalization.Calendar gc = new GregorianCalendar();
DateTime desiretdDT = gc.ToDateTime(1, 1, 1, 0, 0, 0, 0);
Assert.Equal(tbc.MinSupportedDateTime, desiretdDT);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:ThaiBuddhistCalendarMinSupportedDateTime.cs
示例5: AreAnyRoomsInRangeAvailable
/// <summary>
/// Returns false only if all fields for the range has availability set to false
/// </summary>
/// <remarks>
/// This method is useful to checking un-availability, as it will return true if there is any availability in a date range
/// </remarks>
/// <param name="availability">The record to check</param>
/// <param name="fromDayOfYear">From which Day Of Year</param>
/// <param name="toDayOfYear">OPTIONAL: to which Day Of Year, last day in sequence will not be checked will not be checked</param>
/// <returns>True if any of the rooms in the range specified is available otherwise false</returns>
public static bool AreAnyRoomsInRangeAvailable(RoomsAvailability availability, int fromDayOfYear, int? toDayOfYear = null)
{
// if the availability is null means that the room is assumed to be available
if(availability == null)
{
return true;
}
//because we have leap years we need to consider either 365 or 366 days
if (!toDayOfYear.HasValue)
{
GregorianCalendar calendar = new GregorianCalendar();
toDayOfYear = calendar.GetDaysInYear(availability.Year);
}
bool isAvailable = false;
for (int d = fromDayOfYear; d < toDayOfYear; d++)
{
string propertyName = String.Format("IsDay{0:000}Available", d);
PropertyInfo p = typeof(RoomsAvailability).GetProperty(propertyName);
isAvailable = isAvailable | (bool)p.GetValue(availability, null);
}
return isAvailable;
}
开发者ID:ognjenm,项目名称:egle,代码行数:35,代码来源:RoomAvailabilityHelper.cs
示例6: WorkMonth
public WorkMonth(int year, int month, GermanSpecialDays specialDays, IEnumerable<ShortCut> shortCuts, float hoursPerDay)
{
this.year = year;
this.month = month;
this.hoursPerDay = hoursPerDay;
this.Weeks = new ObservableCollection<WorkWeek>();
this.Days = new ObservableCollection<WorkDay>();
this.ShortCutStatistic = new ObservableCollection<KeyValuePair<string, ShortCutStatistic>>();
// TODO which date should i take?
this.ReloadShortcutStatistic(shortCuts);
var cal = new GregorianCalendar();
WorkWeek lastWeek = null;
for (int day = 1; day <= cal.GetDaysInMonth(year, month); day++) {
var dt = new DateTime(year, month, day);
WorkDay wd = new WorkDay(year, month, day, specialDays);
this.Days.Add(wd);
var weekOfYear = cal.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
if (lastWeek == null || lastWeek.WeekOfYear != weekOfYear) {
lastWeek = new WorkWeek(this, weekOfYear);
lastWeek.PropertyChanged += new PropertyChangedEventHandler(this.WeekPropertyChanged);
this.Weeks.Add(lastWeek);
}
lastWeek.AddDay(wd);
}
}
开发者ID:vipwolf,项目名称:moni,代码行数:27,代码来源:WorkMonth.cs
示例7: PosTest1
public void PosTest1()
{
System.Globalization.Calendar tc = new TaiwanCalendar();
System.Globalization.Calendar gc = new GregorianCalendar();
DateTime desiredDT = gc.ToDateTime(1912, 1, 1, 0, 0, 0, 0);
Assert.Equal(desiredDT, tc.MinSupportedDateTime);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:TaiwanCalendarMinSupportedDateTime.cs
示例8: EncodeDate
public static int EncodeDate(DateTime d)
{
int day, month, year;
int c, ya;
GregorianCalendar calendar = new GregorianCalendar();
day = calendar.GetDayOfMonth(d);
month = calendar.GetMonth(d);
year = calendar.GetYear(d);
if (month > 2)
{
month -= 3;
}
else
{
month += 9;
year -= 1;
}
c = year / 100;
ya = year - 100 * c;
return ((146097 * c) / 4 + (1461 * ya) / 4 + (153 * month + 2) / 5 + day + 1721119 - 2400001);
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:26,代码来源:TypeEncoder.cs
示例9: GetCalendarDaysFor
public static List<ActivityDay> GetCalendarDaysFor(int? period/*0=yearly, 1=monthly and 2=weekly*/)
{
var days = new List<ActivityDay>();
//var calendar = new ActivityCalendar();
var calendarYear = new GregorianCalendar();
switch (period)
{
case 0:
var dayNumber=(int)DateTime.Now.DayOfWeek;
var weekDay = DateTime.Now.AddDays(-dayNumber);
for (int i=0;i<7;i++)
{
days.Add(new ActivityDay {
Date = weekDay,
Name = calendarYear.GetDayOfWeek(weekDay).ToString(),
Status=true,
ActivityStatus = calendarYear.GetDayOfWeek(weekDay) == DayOfWeek.Friday ?
DayStatus.Holiday
:DayStatus.Active});
weekDay=weekDay.AddDays(1);
}
break;
case 1:
var daysInMonth=calendarYear.GetDaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
for (int day = 1; day <= daysInMonth;day++ )
{
var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, day);
days.Add(new ActivityDay
{
Date = date,
Name = calendarYear.GetDayOfWeek(date).ToString(),
Status = true,
ActivityStatus = calendarYear.GetDayOfWeek(date) ==
DayOfWeek.Friday ? DayStatus.Holiday : DayStatus.Active
});
}
break;
default:
var daysInYr=calendarYear.GetDaysInYear(DateTime.Now.Year);
var startOfYr = new DateTime(DateTime.Now.Year, 1, 1);
for (int day = 0; day < daysInYr; day++)
{
var dateOfYr = new ActivityDay {Date=startOfYr.AddDays(day) };
dateOfYr.Name = calendarYear.GetDayOfWeek(dateOfYr.Date).ToString();
dateOfYr.Status = true;
dateOfYr.ActivityStatus = calendarYear.GetDayOfWeek(dateOfYr.Date) == DayOfWeek.Friday ? DayStatus.Holiday : DayStatus.Active;
days.Add(dateOfYr);
}
break;
}
return days;
}
开发者ID:naveedjb,项目名称:fahm-e-islam,代码行数:59,代码来源:Utils.cs
示例10: FN_GER_GetWeekOfYear
public static SqlInt32 FN_GER_GetWeekOfYear(SqlDateTime _date)
{
System.Globalization.GregorianCalendar gc = new System.Globalization.GregorianCalendar();
return _date.IsNull ? SqlInt32.Null : gc.GetWeekOfYear(_date.Value, System.Globalization.CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
}
开发者ID:mvasilva,项目名称:SqlServerExtension,代码行数:8,代码来源:Util.cs
示例11: PosTest1
private void PosTest1(GregorianCalendarTypes calendarType)
{
System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
int expectedTwoDigitYearMax, actualTwoDigitYearMax;
expectedTwoDigitYearMax = c_DEFAULT_TWO_DIGIT_YEAR_MAX;
actualTwoDigitYearMax = myCalendar.TwoDigitYearMax;
Assert.Equal(expectedTwoDigitYearMax, actualTwoDigitYearMax);
}
开发者ID:johnhhm,项目名称:corefx,代码行数:8,代码来源:GregorianCalendarTwoDigitYearMax.cs
示例12: PosTest1
public void PosTest1()
{
System.Globalization.Calendar tc = new TaiwanCalendar();
System.Globalization.Calendar gc = new GregorianCalendar();
DateTime desiretdDT = gc.ToDateTime(9999, 12, 31, 23, 59, 59, 999);
desiretdDT = desiretdDT.AddTicks(9999);
Assert.Equal(desiretdDT, tc.MaxSupportedDateTime);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:TaiwanCalendarMaxSupportedDateTime.cs
示例13: Can_Get_IndexOfDay_For_Other_Calendars_Using_CultureHelper
public void Can_Get_IndexOfDay_For_Other_Calendars_Using_CultureHelper()
{
var calendar = new GregorianCalendar();
var dt = new DateTime(2009, 5, 11); //Should be Monday
var dow = CultureHelper.GetDayOfWeek(dt, calendar);
Assert.AreEqual(1, dow);
}
开发者ID:HEskandari,项目名称:FarsiLibrary,代码行数:8,代码来源:InternalTests.cs
示例14: PosTest
// PosTest: Get the MaxSupportedDateTime of Gregorian calendar
private void PosTest(GregorianCalendarTypes calendarType)
{
System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
DateTime expectedTime, actualTime;
expectedTime = DateTime.MaxValue;
actualTime = myCalendar.MaxSupportedDateTime;
Assert.Equal(expectedTime, actualTime);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:GregorianCalendarMaxSupportedDateTime.cs
示例15: GetDaysInYearShouldReturnCorrectCount
public void GetDaysInYearShouldReturnCorrectCount()
{
var target = new GregorianFiscalCalendar( 7 );
var calendar = new GregorianCalendar();
for ( var year = 1998; year <= 2030; year++ )
Assert.Equal( calendar.GetDaysInYear( year ), target.GetDaysInYear( year ) );
}
开发者ID:WaffleSquirrel,项目名称:More,代码行数:8,代码来源:GregorianFiscalCalendarTest.cs
示例16: PosTest2
public void PosTest2()
{
System.Globalization.Calendar kC = new KoreanCalendar();
DateTime maxDT = DateTime.MaxValue;
DateTime expectedValue = new GregorianCalendar().ToDateTime(maxDT.Year, maxDT.Month, maxDT.Day, 0, 0, 0, 0);
DateTime actualValue;
actualValue = kC.AddMonths(expectedValue, -2);
Assert.Equal(kC.GetMonth(expectedValue) - 2, kC.GetMonth(actualValue));
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:KoreanCalendarAddMonths.cs
示例17: PosTest2
public void PosTest2()
{
System.Globalization.Calendar kC = new KoreanCalendar();
DateTime dateTime = new GregorianCalendar().ToDateTime(9999, 12, 31, 0, 0, 0, 0);
int expectedValue = 1;
int actualValue;
actualValue = kC.GetEra(dateTime);
Assert.Equal(expectedValue, actualValue);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:KoreanCalendarGetEra.cs
示例18: PosTest
private void PosTest(GregorianCalendarTypes calendarType)
{
System.Globalization.Calendar myCalendar = new GregorianCalendar(calendarType);
int[] expectedEras, actualEras;
expectedEras = s_ADEra;
actualEras = myCalendar.Eras;
Assert.Equal(expectedEras.Length, actualEras.Length);
Assert.Equal(expectedEras[0], actualEras[0]);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:GregorianCalendarEras.cs
示例19: PosTest3
public void PosTest3()
{
System.Globalization.Calendar kC = new KoreanCalendar();
DateTime dateTime = new GregorianCalendar().ToDateTime(2008, 2, 29, 0, 0, 0, 0);
int expectedValue = 29;
int actualValue;
actualValue = kC.GetDayOfMonth(dateTime);
Assert.Equal(expectedValue, actualValue);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:KoreanCalendarGetDayOfMonth.cs
示例20: BaseDateControl
public BaseDateControl()
{
pc = new PersianCalendar();
gc = new GregorianCalendar();
hc = new HijriCalendar();
SelectedDateTime = DateTime.Now.Date;
ViewDateTime = DateTime.Now.Date;
}
开发者ID:HEskandari,项目名称:FarsiLibrary,代码行数:9,代码来源:BaseDateControl.cs
注:本文中的System.Globalization.GregorianCalendar类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论