public int NumeralVariant; //(Integer) The variant of the digit format to use. /// <summary> /// Constructor using all defaults for the style. /// </summary> public StyleInfo() { BColorLeft = BColorRight = BColorTop = BColorBottom = System.Drawing.Color.Black; // (Color) Color of the bottom border BStyleLeft = BStyleRight = BStyleTop = BStyleBottom = BorderStyleEnum.None; // _BorderWdith BWidthLeft = BWidthRight = BWidthTop = BWidthBottom = 1; BackgroundColor = System.Drawing.Color.Empty; BackgroundColorText = string.Empty; BackgroundGradientType = BackgroundGradientTypeEnum.None; BackgroundGradientEndColor = System.Drawing.Color.Empty; BackgroundImage = null; FontStyle = FontStyleEnum.Normal; _FontFamily = "Arial"; FontSize = 10; FontWeight = FontWeightEnum.Normal; TextDecoration = TextDecorationEnum.None; TextAlign = TextAlignEnum.General; VerticalAlign = VerticalAlignEnum.Top; Color = System.Drawing.Color.Black; ColorText = "Black"; PaddingLeft = PaddingRight = PaddingTop = PaddingBottom = 0; LineHeight = 0; Direction = DirectionEnum.LTR; WritingMode = WritingModeEnum.lr_tb; Language = "en-US"; UnicodeBiDirectional = UnicodeBiDirectionalEnum.Normal; Calendar = CalendarEnum.Gregorian; NumeralLanguage = Language; NumeralVariant = 1; }
public static string ConvertDateCalendar(DateTime DateConv, CalendarEnum Calendar) { DateTimeFormatInfo DTFormat; string date; if (Calendar == CalendarEnum.Hijri) { DTFormat = new System.Globalization.CultureInfo("ar-sa", false).DateTimeFormat; } else { DTFormat = new System.Globalization.CultureInfo("en-us", false).DateTimeFormat; } switch (Calendar) { case CalendarEnum.Hijri: DTFormat.Calendar = new System.Globalization.UmAlQuraCalendar(); DTFormat.ShortDatePattern = "dd/MM/yyyy"; date= DateConv.Date.ToString("dd/MM/yyyy", DTFormat); break; case CalendarEnum.Gregorian: DTFormat.Calendar = new System.Globalization.GregorianCalendar(); CultureInfo arCul = new CultureInfo("ar-SA"); CultureInfo enCul = new CultureInfo("en-US"); DateConv=DateTime.ParseExact(DateConv.Date.ToString("dd/MM/yyyy"),"dd/MM/yyyy",arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces); date = DateConv.ToString("dd/MM/yyyy", enCul.DateTimeFormat); break; default: return ""; } return date; }
/// <summary> /// Gets the calendar (e.g. Gregorian, GregorianArabic, and so on) /// </summary> /// <param name="v"></param> /// <param name="def"></param> /// <returns></returns> public static CalendarEnum GetCalendar(string v, CalendarEnum def) { CalendarEnum c; switch (v.ToLower()) { case "gregorian": c = CalendarEnum.Gregorian; break; case "gregorianarabic": c = CalendarEnum.GregorianArabic; break; case "gregorianmiddleeastfrench": c = CalendarEnum.GregorianMiddleEastFrench; break; case "gregoriantransliteratedenglish": c = CalendarEnum.GregorianTransliteratedEnglish; break; case "gregoriantransliteratedfrench": c = CalendarEnum.GregorianTransliteratedFrench; break; case "gregorianusenglish": c = CalendarEnum.GregorianUSEnglish; break; case "hebrew": c = CalendarEnum.Hebrew; break; case "hijri": c = CalendarEnum.Hijri; break; case "japanese": c = CalendarEnum.Japanese; break; case "korea": c = CalendarEnum.Korea; break; case "taiwan": c = CalendarEnum.Taiwan; break; case "thaibuddhist": c = CalendarEnum.ThaiBuddhist; break; default: c = def; break; } return(c); }
public override int GetMaximum(CalendarEnum field) { switch (field) { case CalendarEnum.Year: return(DateTime.MaxValue.Year); case CalendarEnum.Month: return(11); case CalendarEnum.MonthOneBased: return(12); case CalendarEnum.DayOfMonth: return(DateTime.DaysInMonth(GetTime().Year, GetTime().Month)); case CalendarEnum.Hour: return(23); case CalendarEnum.HourOfDay: return(23); case CalendarEnum.Minute: return(60); case CalendarEnum.Second: return(60); case CalendarEnum.Millisecond: return(999); } throw new NotSupportedException(); }
public int Get(CalendarEnum field) { switch (field) { case CalendarEnum.Year: return(_mCalendarDate.Year); case CalendarEnum.Month: return(_mCalendarDate.Month - 1); case CalendarEnum.MonthOneBased: return(_mCalendarDate.Month); case CalendarEnum.DayOfMonth: return(_mCalendarDate.Day); case CalendarEnum.Hour: case CalendarEnum.HourOfDay: return(_mCalendarDate.Hour); case CalendarEnum.Minute: return(_mCalendarDate.Minute); case CalendarEnum.Second: return(_mCalendarDate.Second); case CalendarEnum.Millisecond: return(_mCalendarDate.Millisecond); } throw new NotSupportedException(); }
public override int GetMaximum(CalendarEnum field) { switch (field) { case CalendarEnum.Year: return DateTime.MaxValue.Year; case CalendarEnum.Month: return 11; case CalendarEnum.MonthOneBased: return 12; case CalendarEnum.DayOfMonth: return DateTime.DaysInMonth(GetTime().Year, GetTime().Month); case CalendarEnum.Hour: return 23; case CalendarEnum.HourOfDay: return 23; case CalendarEnum.Minute: return 60; case CalendarEnum.Second: return 60; case CalendarEnum.Millisecond: return 999; } throw new NotSupportedException(); }
public static DateTime GetNextDay(CalendarEnum day, DateTime startDate) { var desiredDate = startDate; while ((int)desiredDate.DayOfWeek != (int)day) { desiredDate = desiredDate.AddDays(1); } return(desiredDate); }
/// <summary> /// Gets the calendar (e.g. Gregorian, GregorianArabic, and so on) /// </summary> /// <param name="v"></param> /// <param name="def"></param> /// <returns></returns> public static CalendarEnum GetCalendar(string v, CalendarEnum def) { CalendarEnum c; try { c = (CalendarEnum)Enum.Parse(typeof(CalendarEnum), v); } catch { c = def; } return(c); }
public int NumeralVariant; //(Integer) The variant of the digit format to use. /// <summary> /// Constructor using all defaults for the style. /// </summary> public StyleInfo() { BColorLeft = BColorRight = BColorTop = BColorBottom = System.Drawing.Color.Black; // (Color) Color of the bottom border BStyleLeft = BStyleRight = BStyleTop = BStyleBottom = BorderStyleEnum.None; // _BorderWdith BWidthLeft = BWidthRight = BWidthTop = BWidthBottom = 1; BackgroundColor = System.Drawing.Color.Empty; BackgroundColorText = string.Empty; BackgroundGradientType = BackgroundGradientTypeEnum.None; BackgroundGradientEndColor = System.Drawing.Color.Empty; BackgroundImage = null; FontStyle = FontStyleEnum.Normal; _FontFamily = "Arial"; //WRP 291008 numFmtId should be 0 (Zero) for General format - will be interpreted as a string //It has default values in Excel07 as per ECMA-376 standard (SEction 3.8.30) for Office Open XML Excel07 _Format = "General"; FontSize = 10; FontWeight = FontWeightEnum.Normal; PatternType = patternTypeEnum.None; TextDecoration = TextDecorationEnum.None; TextAlign = TextAlignEnum.General; VerticalAlign = VerticalAlignEnum.Top; Color = System.Drawing.Color.Black; ColorText = "Black"; PaddingLeft = PaddingRight = PaddingTop = PaddingBottom = 0; LineHeight = 0; Direction = DirectionEnum.LTR; WritingMode = WritingModeEnum.lr_tb; Language = "en-US"; UnicodeBiDirectional = UnicodeBiDirectionalEnum.Normal; Calendar = CalendarEnum.Gregorian; NumeralLanguage = Language; NumeralVariant = 1; }
private static List <EventDate> GetEvents(string country, CalendariumConfiguration calculated, int year, CalendarEnum calendar = CalendarEnum.Default) { var dates = calculated.GetDates(year, country, calendar); List <EventDate> _events = new List <EventDate>(); foreach (var _date in dates) { foreach (var _event in _date.Value.Events) { _events.Add(_event); } } return(_events.OrderBy(c => c.Date.OriginalDate).ThenByDescending(c => c.Name).ToList()); }
public abstract int GetMaximum(CalendarEnum field);
public void Set(CalendarEnum field, int value) { var max = GetMaximum(field); var mod = max + 1; switch (field) { case CalendarEnum.Year: // to avoid exception which is absent in Calendar value = value % mod; _mCalendarDate = _mCalendarDate.AddYears(value - _mCalendarDate.Year); return; case CalendarEnum.Month: _mCalendarDate = _mCalendarDate.AddMonths((value + 1) - _mCalendarDate.Month); return; case CalendarEnum.MonthOneBased: _mCalendarDate = _mCalendarDate.AddMonths(value - _mCalendarDate.Month); return; case CalendarEnum.DayOfMonth: _mCalendarDate = _mCalendarDate.AddDays(value - _mCalendarDate.Day); return; case CalendarEnum.Hour: _mCalendarDate = _mCalendarDate.AddHours(value - _mCalendarDate.Hour); return; case CalendarEnum.HourOfDay: // hour of day has max value == 24, which means next day if (value == 24) { Set(CalendarEnum.Hour, 0); _mCalendarDate = _mCalendarDate.AddDays(1); } else { Set(CalendarEnum.Hour, value); } return; case CalendarEnum.Minute: _mCalendarDate = _mCalendarDate.AddMinutes(value - _mCalendarDate.Minute); return; case CalendarEnum.Second: _mCalendarDate = _mCalendarDate.AddSeconds(value - _mCalendarDate.Second); return; case CalendarEnum.Millisecond: //m_calendarDate = m_calendarDate.AddMilliseconds(value - m_calendarDate.Millisecond); // this not works right, because of miliseconds fraction, so we need to go another way here _mCalendarDate = new DateTime(_mCalendarDate.Year, _mCalendarDate.Month, _mCalendarDate.Day, _mCalendarDate.Hour, _mCalendarDate.Minute, _mCalendarDate.Second, value, _mCalendarDate.Kind); return; } throw new NotSupportedException(); }
public int NumeralVariant; //(Integer) The variant of the digit format to use. /// <summary> /// Constructor using all defaults for the style. /// </summary> public StyleInfo() { BColorLeft = BColorRight = BColorTop = BColorBottom = System.Drawing.Color.Black; // (Color) Color of the bottom border BStyleLeft = BStyleRight = BStyleTop = BStyleBottom = BorderStyleEnum.None; // _BorderWdith BWidthLeft = BWidthRight = BWidthTop = BWidthBottom = 1; BackgroundColor = System.Drawing.Color.Empty; BackgroundColorText = string.Empty; BackgroundGradientType = BackgroundGradientTypeEnum.None; BackgroundGradientEndColor = System.Drawing.Color.Empty; BackgroundImage = null; FontStyle = FontStyleEnum.Normal; _FontFamily = "Arial"; //WRP 291008 numFmtId should be 0 (Zero) for General format - will be interpreted as a string //It has default values in Excel07 as per ECMA-376 standard (SEction 3.8.30) for Office Open XML Excel07 _Format = "General"; FontSize = 10; FontWeight = FontWeightEnum.Normal; PatternType = patternTypeEnum.None; TextDecoration = TextDecorationEnum.None; TextAlign = TextAlignEnum.General; VerticalAlign = VerticalAlignEnum.Top; Color = System.Drawing.Color.Black; ColorText = "Black"; PaddingLeft = PaddingRight = PaddingTop = PaddingBottom = 0; LineHeight = 0; Direction = DirectionEnum.LTR; WritingMode = WritingModeEnum.lr_tb; Language = "en-US"; UnicodeBiDirectional = UnicodeBiDirectionalEnum.Normal; Calendar = CalendarEnum.Gregorian; NumeralLanguage = Language; NumeralVariant=1; }
public int NumeralVariant; //(Integer) The variant of the digit format to use. /// <summary> /// Constructor using all defaults for the style. /// </summary> public StyleInfo() { BColorLeft = BColorRight = BColorTop = BColorBottom = System.Drawing.Color.Black; // (Color) Color of the bottom border BStyleLeft = BStyleRight = BStyleTop = BStyleBottom = BorderStyleEnum.None; // _BorderWdith BWidthLeft = BWidthRight = BWidthTop = BWidthBottom = 1; BackgroundColor = System.Drawing.Color.Empty; BackgroundGradientType = BackgroundGradientTypeEnum.None; BackgroundGradientEndColor = System.Drawing.Color.Empty; BackgroundImage = null; FontStyle = FontStyleEnum.Normal; _FontFamily = "Arial"; FontSize = 10; FontWeight = FontWeightEnum.Normal; TextDecoration = TextDecorationEnum.None; TextAlign = TextAlignEnum.Left; VerticalAlign = VerticalAlignEnum.Top; Color = System.Drawing.Color.Black; PaddingLeft = PaddingRight = PaddingTop = PaddingBottom = 0; LineHeight = 0; Direction = DirectionEnum.LTR; WritingMode = WritingModeEnum.lr_tb; Language = "en-US"; UnicodeBiDirectional = UnicodeBiDirectionalEnum.Normal; Calendar = CalendarEnum.Gregorian; NumeralLanguage = Language; NumeralVariant=1; }
public static Calendar GetCalendar(this CalendarEnum self, CultureInfo culture = null) { Calendar calendar = null; switch (self) { case CalendarEnum.Gregorian: calendar = new GregorianCalendar(); break; case CalendarEnum.Hebrew: calendar = new HebrewCalendar(); break; case CalendarEnum.UmAlQura: calendar = new UmAlQuraCalendar(); break; case CalendarEnum.Hijri: calendar = new HijriCalendar(); break; case CalendarEnum.Japanese: calendar = new JapaneseCalendar(); break; case CalendarEnum.JapaneseLunisolar: calendar = new JapaneseLunisolarCalendar(); break; case CalendarEnum.Julian: calendar = new JulianCalendar(); break; case CalendarEnum.Korean: calendar = new KoreanCalendar(); break; case CalendarEnum.KoreanLunisolar: calendar = new KoreanLunisolarCalendar(); break; case CalendarEnum.Persian: calendar = new PersianCalendar(); break; case CalendarEnum.Taiwan: calendar = new TaiwanCalendar(); break; case CalendarEnum.TaiwanLunisolar: calendar = new TaiwanLunisolarCalendar(); break; case CalendarEnum.ThaiBuddhist: calendar = new ThaiBuddhistCalendar(); break; default: if (culture == null) { culture = System.Threading.Thread.CurrentThread.CurrentCulture; } calendar = culture.Calendar; break; } return(calendar); }
public int Get(CalendarEnum field) { switch (field) { case CalendarEnum.Year: return _mCalendarDate.Year; case CalendarEnum.Month: return _mCalendarDate.Month - 1; case CalendarEnum.MonthOneBased: return _mCalendarDate.Month; case CalendarEnum.DayOfMonth: return _mCalendarDate.Day; case CalendarEnum.Hour: case CalendarEnum.HourOfDay: return _mCalendarDate.Hour; case CalendarEnum.Minute: return _mCalendarDate.Minute; case CalendarEnum.Second: return _mCalendarDate.Second; case CalendarEnum.Millisecond: return _mCalendarDate.Millisecond; } throw new NotSupportedException(); }
public abstract int GetMaximum(CalendarEnum field);
/// <summary> /// Gets the calendar (e.g. Gregorian, GregorianArabic, and so on) /// </summary> /// <param name="v"></param> /// <param name="def"></param> /// <returns></returns> public static CalendarEnum GetCalendar(string v, CalendarEnum def) { CalendarEnum c; switch (v.ToLower()) { case "gregorian": c = CalendarEnum.Gregorian; break; case "gregorianarabic": c = CalendarEnum.GregorianArabic; break; case "gregorianmiddleeastfrench": c = CalendarEnum.GregorianMiddleEastFrench; break; case "gregoriantransliteratedenglish": c = CalendarEnum.GregorianTransliteratedEnglish; break; case "gregoriantransliteratedfrench": c = CalendarEnum.GregorianTransliteratedFrench; break; case "gregorianusenglish": c = CalendarEnum.GregorianUSEnglish; break; case "hebrew": c = CalendarEnum.Hebrew; break; case "hijri": c = CalendarEnum.Hijri; break; case "japanese": c = CalendarEnum.Japanese; break; case "korea": c = CalendarEnum.Korea; break; case "taiwan": c = CalendarEnum.Taiwan; break; case "thaibuddhist": c = CalendarEnum.ThaiBuddhist; break; default: c = def; break; } return c; }
private List <PeriodConfiguration> ParsePeriods(List <PeriodConfiguration> periods, CultureInfo culture, CalendarEnum calendarCountry, string country, string key) { List <PeriodConfiguration> list; Calendar _cal = calendarCountry.GetCalendar(culture); if (string.IsNullOrEmpty(key)) { list = GetList(country.ToString()); } else { list = GetList($"{country.ToString()}-{key}"); } foreach (var periodReference in periods) { periodReference.CultureInfo = culture; if (periodReference.Calendar == CalendarEnum.Default) { periodReference.Calendar = calendarCountry; } var _calendar = periodReference.Calendar.GetCalendar(periodReference.CultureInfo); if (periodReference.RuleDate != null && periodReference.RuleFunction == null) { periodReference.RuleFunction = _parser.ParseRuleString(periodReference.RuleDate.ToUpper(), periodReference.Name, country, _calendar); } if (periodReference.RuleDuration != null && periodReference.RuleDurationFunction == null) { if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } //periodReference.RuleDurationFunction = _parser.ParseRuleString(periodReference.RuleDuration.ToUpper()); } if (periodReference.RuleObserved != null && periodReference.RuleObservedFunction == null) { periodReference.RuleObservedFunction = _parser.ParseRuleObservedString(periodReference.RuleObserved.ToUpper(), periodReference.Name, country, _calendar); } var newPeriod = periodReference.Clone(); list.Add(newPeriod); } return(list); }
/// <summary> /// Gets the calendar (e.g. Gregorian, GregorianArabic, and so on) /// </summary> /// <param name="v"></param> /// <param name="def"></param> /// <returns></returns> public static CalendarEnum GetCalendar(string v, CalendarEnum def) { CalendarEnum c; try { c = (CalendarEnum)Enum.Parse(typeof(CalendarEnum), v); } catch { c = def; } return c; }
public void Set(CalendarEnum field, int value) { var max = GetMaximum(field); var mod = max + 1; switch (field) { case CalendarEnum.Year: // to avoid exception which is absent in Calendar value = value % mod; _mCalendarDate = _mCalendarDate.AddYears(value - _mCalendarDate.Year); return; case CalendarEnum.Month: _mCalendarDate = _mCalendarDate.AddMonths(value + 1 - _mCalendarDate.Month); return; case CalendarEnum.MonthOneBased: _mCalendarDate = _mCalendarDate.AddMonths(value - _mCalendarDate.Month); return; case CalendarEnum.DayOfMonth: _mCalendarDate = _mCalendarDate.AddDays(value - _mCalendarDate.Day); return; case CalendarEnum.Hour: _mCalendarDate = _mCalendarDate.AddHours(value - _mCalendarDate.Hour); return; case CalendarEnum.HourOfDay: // hour of day has max value == 24, which means next day if (value == 24) { Set(CalendarEnum.Hour, 0); _mCalendarDate = _mCalendarDate.AddDays(1); } else { Set(CalendarEnum.Hour, value); } return; case CalendarEnum.Minute: _mCalendarDate = _mCalendarDate.AddMinutes(value - _mCalendarDate.Minute); return; case CalendarEnum.Second: _mCalendarDate = _mCalendarDate.AddSeconds(value - _mCalendarDate.Second); return; case CalendarEnum.Millisecond: //m_calendarDate = m_calendarDate.AddMilliseconds(value - m_calendarDate.Millisecond); // this not works right, because of milliseconds fraction, so we need to go another way here _mCalendarDate = new DateTime( _mCalendarDate.Year, _mCalendarDate.Month, _mCalendarDate.Day, _mCalendarDate.Hour, _mCalendarDate.Minute, _mCalendarDate.Second, value, _mCalendarDate.Kind); return; } throw new NotSupportedException(); }