public HomeController() { DbInitializer.Initialize(); profiler = MiniProfiler.Current; EasternStandardTimeId = "Eastern Standard Time"; ESTTimeZone = TimeZoneInfo.FindSystemTimeZoneById(EasternStandardTimeId); }
public ScheduleInstant(DateTime nowInstant, TimeZoneInfo timeZone, [NotNull] CrontabSchedule schedule) { if (schedule == null) throw new ArgumentNullException("schedule"); if (nowInstant.Kind != DateTimeKind.Utc) { throw new ArgumentException("Only DateTime values in UTC should be passed.", "nowInstant"); } _timeZone = timeZone; _schedule = schedule; NowInstant = nowInstant.AddSeconds(-nowInstant.Second); var nextOccurrences = _schedule.GetNextOccurrences( TimeZoneInfo.ConvertTime(NowInstant, TimeZoneInfo.Utc, _timeZone), DateTime.MaxValue); foreach (var nextOccurrence in nextOccurrences) { if (_timeZone.IsInvalidTime(nextOccurrence)) continue; NextInstant = TimeZoneInfo.ConvertTime(nextOccurrence, _timeZone, TimeZoneInfo.Utc); break; } }
public ITimeZone AddTimeZone(System.TimeZoneInfo tzi, DateTime earliestDateTimeToSupport, bool includeHistoricalData) { ITimeZone tz = iCalTimeZone.FromSystemTimeZone(tzi, earliestDateTimeToSupport, includeHistoricalData); this.AddChild(tz); return(tz); }
private static iCalDateTime CalcTransitionStart(TimeZoneInfo.TransitionTime transition, int year) { // For non-fixed date rules, get local calendar Calendar cal = CultureInfo.CurrentCulture.Calendar; // Get first day of week for transition // For example, the 3rd week starts no earlier than the 15th of the month int startOfWeek = transition.Week * 7 - 6; // What day of the week does the month start on? int firstDayOfWeek = (int)cal.GetDayOfWeek(new DateTime(year, transition.Month, 1)); // Determine how much start date has to be adjusted int transitionDay; int changeDayOfWeek = (int)transition.DayOfWeek; if (firstDayOfWeek <= changeDayOfWeek) transitionDay = startOfWeek + (changeDayOfWeek - firstDayOfWeek); else transitionDay = startOfWeek + (7 - firstDayOfWeek + changeDayOfWeek); // Adjust for months with no fifth week if (transitionDay > cal.GetDaysInMonth(year, transition.Month)) transitionDay -= 7; return new iCalDateTime(new DateTime( year, transition.Month, transitionDay, transition.TimeOfDay.Hour, transition.TimeOfDay.Minute, transition.TimeOfDay.Second)); }
public void SystemTimeZone2() { System.TimeZoneInfo tzi = System.TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time"); Assert.IsNotNull(tzi); iCalendar iCal = new iCalendar(); ITimeZone tz = iCal.AddTimeZone(tzi); Assert.IsNotNull(tz); iCalendarSerializer serializer = new iCalendarSerializer(); serializer.Serialize(iCal, @"Calendars\Serialization\SystemTimeZone2.ics"); iCalDateTime dt1 = new iCalDateTime(2003, 10, 26, 0, 59, 59, tz.TZID, iCal); iCalDateTime dt2 = new iCalDateTime(2003, 10, 26, 1, 0, 0, tz.TZID, iCal); TimeSpan result = dt2 - dt1; Assert.AreEqual(TimeSpan.FromHours(1) + TimeSpan.FromSeconds(1), result); dt1 = new iCalDateTime(2004, 4, 4, 1, 59, 59, tz.TZID, iCal); dt2 = new iCalDateTime(2004, 4, 4, 2, 0, 0, tz.TZID, iCal); result = dt2 - dt1; Assert.AreEqual(TimeSpan.FromHours(-1) + TimeSpan.FromSeconds(1), result); }
/// <summary> /// This method will return a signed four digit integer indicating the /// GMT offset for the given TimeZoneInfo when applied to the given DateTime. /// This is the HL7 Offset format in integer representation. /// </summary> public static int GetGMTOffset(TimeZoneInfo timeZone, DateTime time) { var gmtOffSet = timeZone.GetUtcOffset(time); //return the offset value HL7 format return gmtOffSet.Hours*100 + gmtOffSet.Minutes; }
/// <summary> /// Initializes this transition based on the specified transition time. /// </summary> /// <param name="transitionTime">The transition time to initialize from.</param> internal override void InitializeFromTransitionTime(TimeZoneInfo.TransitionTime transitionTime) { base.InitializeFromTransitionTime(transitionTime); this.timeOffset = transitionTime.TimeOfDay.TimeOfDay; this.month = transitionTime.Month; }
/// <summary> /// Uses now as a basis to calculate the next scheduled date. /// </summary> /// <param name="tzi">user's time zone</param> /// <param name="recurrence">pattern</param> /// <param name="timeOfDay">user's preferred time of day, in user's time zone</param> /// <param name="userTime">start time in user time zone</param> /// <param name="utc">start time in utc</param> /// <returns>false if not within start-end period, true otherwise</returns> public static bool CalculateStartTime(TimeZoneInfo tzi, string recurrence, TimeSpan timeOfDay, out DateTime userTime, out DateTime utc) { DateTime utcNow = DateTime.UtcNow; userTime = utc = DateTime.MinValue; TimeSpan? ts = ScheduledTask.FixedInterval(recurrence); if (ts.HasValue) { utc = utcNow + ts.Value; userTime = TimeZoneInfo.ConvertTimeFromUtc(utc, tzi); } else { DateTime userNow = TimeZoneInfo.ConvertTimeFromUtc(utcNow, tzi); DateTime runDate = userNow.Date; if (userNow.TimeOfDay > timeOfDay) runDate += TimeSpan.FromDays(1); DateTime dt; if (recurrence != null) { DateGenerator gen = DateGeneratorFactory.Create(recurrence); DateTime next = gen.OnOrAfter(runDate); if (next == default(DateTime)) return false; // outside range dt = next + timeOfDay; } else { dt = runDate + timeOfDay; } userTime = dt; utc = TimeZoneInfo.ConvertTimeToUtc(dt, tzi); } return true; }
public static DateTime? DateTimeInUserZone(DateTime dt, TimeZoneInfo userZone) { if (dt.Kind == DateTimeKind.Local) throw new ArgumentException("Invalid date kind (local"); if (dt == default(DateTime)) return null; // we don't want to display 0001-01-01T00:00:00 if (dt.Kind == DateTimeKind.Utc) dt = TimeZoneInfo.ConvertTimeFromUtc(dt, userZone); return dt; }
public FirstViewController(IntPtr handle) : base(handle) { this.Title = NSBundle.MainBundle.LocalizedString ("First", "First"); this.TabBarItem.Image = UIImage.FromBundle ("first"); this.selectedTimeZone = TimeZoneInfo.Local; }
public RecurringJobSchedulerFacts() { _storage = new Mock<JobStorage>(); _client = new Mock<IBackgroundJobClient>(); _instantFactory = new Mock<IScheduleInstantFactory>(); _throttler = new Mock<IThrottler>(); _token = new CancellationTokenSource().Token; // Setting up the successful path _instant = new Mock<IScheduleInstant>(); _instant.Setup(x => x.GetNextInstants(It.IsAny<DateTime?>())).Returns(new[] { _instant.Object.NowInstant }); _timeZone = TimeZoneInfo.Local; _instantFactory.Setup(x => x.GetInstant(It.IsNotNull<CrontabSchedule>(), It.IsNotNull<TimeZoneInfo>())) .Returns(() => _instant.Object); _recurringJob = new Dictionary<string, string> { { "Cron", "* * * * *" }, { "Job", JobHelper.ToJson(InvocationData.Serialize(Job.FromExpression(() => Console.WriteLine()))) }, { "TimeZoneId", _timeZone.Id } }; _connection = new Mock<IStorageConnection>(); _storage.Setup(x => x.GetConnection()).Returns(_connection.Object); _connection.Setup(x => x.GetAllItemsFromSet("recurring-jobs")) .Returns(new HashSet<string> { RecurringJobId }); _connection.Setup(x => x.GetAllEntriesFromHash(String.Format("recurring-job:{0}", RecurringJobId))) .Returns(_recurringJob); _client.Setup(x => x.Create(It.IsAny<Job>(), It.IsAny<IState>())).Returns("job-id"); }
public static void Go() { LN_TZI = TimeZoneInfo.GetSystemTimeZones().Where(x => x.DisplayName.Contains("London")).FirstOrDefault(); UTC_TZI = TimeZoneInfo.GetSystemTimeZones().Where(x => x.Id.Equals("UTC")).FirstOrDefault(); //DateTime jan = new DateTime(2011, 1, 1, 7, 0, 0, DateTimeKind.Utc); //DateTime aug = new DateTime(2011, 8, 1, 7, 0, 0, DateTimeKind.Utc); //var janDS = (LN_TZI.IsDaylightSavingTime(jan)); //var augDS = (LN_TZI.IsDaylightSavingTime(aug)); //var janDS_Offset = LN_TZI.GetUtcOffset(jan); //var augDS_Offset = LN_TZI.GetUtcOffset(aug); //Console.WriteLine(janDS_Offset); //Console.WriteLine(augDS_Offset); //foreach (var ts in TimeZoneInfo.GetSystemTimeZones()) //{ // Console.WriteLine(string.Format("{0} -> {1}",ts.Id,ts.DisplayName)); //} goOne(); //goTwo(); }
static DateTimeConverter() { LocalZoneInfo = TimeZoneInfo.Local; CurrentZone = TimeZone.CurrentTimeZone; var offset = LocalZoneInfo.BaseUtcOffset; var sbWithout = new StringBuilder(); if (offset.TotalSeconds >= 0) sbWithout.Append('+'); sbWithout.Append(offset.Hours.ToString("00")); sbWithout.Append(':'); sbWithout.Append(offset.Minutes.ToString("00")); //tough luck if you have seconds in timezone offset TimeZoneWithoutDaylightSaving = sbWithout.ToString(); var rules = LocalZoneInfo.GetAdjustmentRules(); if (rules.Length == 1 && rules[0].DateStart == DateTime.MinValue && rules[0].DateEnd == DateTime.MinValue) { var sbWith = new StringBuilder(); var totalOffset = offset.Add(rules[0].DaylightDelta); if (totalOffset.TotalSeconds >= 0) sbWith.Append('+'); sbWith.Append(totalOffset.Hours.ToString("00")); sbWith.Append(':'); sbWith.Append(totalOffset.Minutes.ToString("00")); TimeZoneWithDaylightSaving = sbWith.ToString(); } }
/// <summary> /// Get current IP Camera's time zone and time. /// </summary> /// <returns></returns> void GetTime(out DateTime timeUtc, out TimeZoneInfo timeZone, out string ntpServer, out bool useNtp) { ///GetTime.cgi[?JsVar=variable[&OnJs=function]] timeUtc = DateTime.MinValue; timeZone = TimeZoneInfo.Local; ntpServer = ""; useNtp = false; RovioResponse dic = this.Request("/GetTime.cgi"); if (dic == null) return; long sec1970; if (!(dic.ContainsKey("Sec1970") && long.TryParse(dic["Sec1970"], out sec1970))) return; int timeZoneMinutes; if (!(dic.ContainsKey("TimeZone") && int.TryParse(dic["TimeZone"], out timeZoneMinutes))) return; DateTime date1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); timeUtc = date1970.AddSeconds(sec1970); timeZone = CreateTimeZone(TimeSpan.FromMinutes(-timeZoneMinutes)); ntpServer = dic.ContainsKey("NtpServer") ? dic["NtpServer"] : ""; useNtp = dic.ContainsKey("UseNtp") ? (dic["UseNtp"] == "1") : false; }
public void SystemTimeZone2() { System.TimeZoneInfo tzi = System.TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time"); Assert.IsNotNull(tzi); iCalendar iCal = new iCalendar(); ITimeZone tz = iCal.AddTimeZone(tzi, new DateTime(2000, 1, 1), false); Assert.IsNotNull(tz); iCalendarSerializer serializer = new iCalendarSerializer(); serializer.Serialize(iCal, @"Calendars\Serialization\SystemTimeZone2.ics"); // Ensure the time zone transition works as expected // (i.e. it takes 1 hour and 1 second to transition from // 2003-10-26 1:59:59 AM to // 2003-10-26 2:00:00 AM) iCalDateTime dt1 = new iCalDateTime(2003, 10, 26, 1, 59, 59, tz.TZID, iCal); iCalDateTime dt2 = new iCalDateTime(2003, 10, 26, 2, 0, 0, tz.TZID, iCal); TimeSpan result = dt2 - dt1; Assert.AreEqual(TimeSpan.FromHours(1) + TimeSpan.FromSeconds(1), result); // Ensure another time zone transition works as expected // (i.e. it takes negative 59 minutes and 59 seconds to transition from // 2004-04-04 1:59:59 AM to // 2004-04-04 2:00:00 AM) dt1 = new iCalDateTime(2004, 4, 4, 1, 59, 59, tz.TZID, iCal); dt2 = new iCalDateTime(2004, 4, 4, 2, 0, 0, tz.TZID, iCal); result = dt2 - dt1; Assert.AreEqual(TimeSpan.FromHours(-1) + TimeSpan.FromSeconds(1), result); }
/// <summary> /// 获取程序集的链接时间 /// </summary> /// <param name="assembly"></param> /// <param name="target"></param> /// <returns></returns> public static DateTime GetLinkerTime(Assembly assembly, TimeZoneInfo target = null) { var filePath = assembly.Location; const int c_PeHeaderOffset = 60; const int c_LinkerTimestampOffset = 8; var buffer = new byte[2048]; using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) stream.Read(buffer, 0, 2048); var offset = BitConverter.ToInt32(buffer, c_PeHeaderOffset); var secondsSince1970 = BitConverter.ToInt32(buffer, offset + c_LinkerTimestampOffset); var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var linkTimeUtc = epoch.AddSeconds(secondsSince1970); var tz = target; try { if (tz == null) tz = TimeZoneInfo.Local; } catch { tz = TimeZoneInfo.Utc; } var localTime = TimeZoneInfo.ConvertTimeFromUtc(linkTimeUtc, tz); return localTime; }
private static void Dump(TimeZoneInfo zone, Options options, TextWriter writer) { writer.Write($"{zone.Id}\n"); // This will be a bit odd using Windows time zones, as most have permanent // daylight saving rules... but for tz data, it should be okay. var initial = new DateTimeOffset(2, 1, 1, 0, 0, 0, 0, TimeSpan.Zero); var initialOffset = zone.GetUtcOffset(initial); var initialDaylight = zone.IsDaylightSavingTime(initial); writer.Write("Initially: {0} {1} {2}\n", (initialOffset.Ticks >= 0 ? "+" : "-") + initialOffset.ToString("hh':'mm':'ss", CultureInfo.InvariantCulture), initialDaylight ? "daylight" : "standard", initialDaylight ? zone.DaylightName : zone.StandardName); int fromYear = options.FromYear ?? 1800; DateTimeOffset start = new DateTimeOffset(fromYear, 1, 1, 0, 0, 0, TimeSpan.Zero); DateTimeOffset end = new DateTimeOffset(options.ToYear, 1, 1, 0, 0, 0, TimeSpan.Zero); DateTimeOffset? transition = GetNextTransition(zone, start.AddTicks(-1), end); while (transition != null) { var offset = zone.GetUtcOffset(transition.Value); var isDaylight = zone.IsDaylightSavingTime(transition.Value); // It's unfortunate that TimeZoneInfo doesn't support the idea of different names // for different periods in history. Never mind - this is better than nothing, // for diagnostic purposes. writer.Write("{0} {1} {2} {3}\n", transition.Value.ToString("yyyy-MM-dd HH:mm:ss'Z'", CultureInfo.InvariantCulture), (offset.Ticks >= 0 ? "+" : "-") + offset.ToString("hh':'mm':'ss", CultureInfo.InvariantCulture), isDaylight ? "daylight" : "standard", isDaylight ? zone.DaylightName : zone.StandardName); transition = GetNextTransition(zone, transition.Value, end); } writer.Write("\n"); }
public ZonedDateTime(DateTime dateTime, TimeZoneInfo timeZoneInfo) { this._original = dateTime; this._utc = TimeZoneInfo.ConvertTimeToUtc(dateTime, timeZoneInfo); this._local = TimeZoneInfo.ConvertTime(this._utc, TimeZoneInfo.Local); this._timeZoneInfo = timeZoneInfo; }
public static DateTime? ToTimeZone(this DateTime? utcTime, TimeZoneInfo timeZoneInfo) { if (!utcTime.HasValue) return null; return ToTimeZone(utcTime.Value, timeZoneInfo); }
public StringToTimeCase(string str, int start, string result, TimeZoneInfo[] zones) { this.String = str; this.StartTime = start; this.Result = result; this.Zones = zones; }
public static DateTime? ToUtc(this DateTime? dateTime, TimeZoneInfo timeZoneInfo) { if (!dateTime.HasValue) return null; return ToUtc(dateTime.Value, timeZoneInfo); }
/// <summary> /// Initializes a new instance of the <see cref="LegacyAvailabilityTimeZoneTime"/> class. /// </summary> /// <param name="transitionTime">The transition time used to initialize this instance.</param> /// <param name="delta">The offset used to initialize this instance.</param> internal LegacyAvailabilityTimeZoneTime(TimeZoneInfo.TransitionTime transitionTime, TimeSpan delta) : this() { this.delta = delta; if (transitionTime.IsFixedDateRule) { // TimeZoneInfo doesn't support an actual year. Fixed date transitions occur at the same // date every year the adjustment rule the transition belongs to applies. The best thing // we can do here is use the current year. this.year = DateTime.Today.Year; this.month = transitionTime.Month; this.dayOrder = transitionTime.Day; this.timeOfDay = transitionTime.TimeOfDay.TimeOfDay; } else { // For floating rules, the mapping is direct. this.year = 0; this.month = transitionTime.Month; this.dayOfTheWeek = EwsUtilities.SystemToEwsDayOfTheWeek(transitionTime.DayOfWeek); this.dayOrder = transitionTime.Week; this.timeOfDay = transitionTime.TimeOfDay.TimeOfDay; } }
public static DateTime ToTimeZone(this DateTime utcTime, TimeZoneInfo timeZoneInfo) { if (timeZoneInfo == null) return utcTime.ToLocalTime(); return TimeZoneInfo.ConvertTimeFromUtc(utcTime, timeZoneInfo); }
public static void FixTimeZoneDSTRRules (TimeZoneInfo tz, ITimeZone iCalTz) { var adjustments = tz.GetAdjustmentRules(); foreach (var tziItems in iCalTz.TimeZoneInfos) { var matchingAdj = adjustments.FirstOrDefault(a => (a.DateStart.Year == tziItems.Start.Year)) ?? adjustments.FirstOrDefault(); if (matchingAdj != null) { if ((matchingAdj.DateEnd.Year != 9999) && !(tziItems.Name.Equals("STANDARD") && matchingAdj == adjustments.Last())) { tziItems.RecurrenceRules[0].Until = DateTime.SpecifyKind(matchingAdj.DateEnd.Date.AddDays(1).Subtract(tz.BaseUtcOffset), DateTimeKind.Utc); } if (tziItems.Name.Equals("STANDARD")) { if (!matchingAdj.DaylightTransitionEnd.IsFixedDateRule) { var startYear = tziItems.Start.Year; tziItems.Start = CalcTransitionStart(matchingAdj.DaylightTransitionEnd, startYear); } } else { if (!matchingAdj.DaylightTransitionStart.IsFixedDateRule) { var startYear = tziItems.Start.Year; tziItems.Start = CalcTransitionStart(matchingAdj.DaylightTransitionStart, startYear); } } } } }
public IScheduleInstant GetInstant(CrontabSchedule schedule, TimeZoneInfo timeZone) { if (schedule == null) throw new ArgumentNullException("schedule"); if (timeZone == null) throw new ArgumentNullException("timeZone"); return new ScheduleInstant(DateTime.UtcNow, timeZone, schedule); }
public static DateTime GetDateFromDynamic(DateMagnitude magnitude, int offset, bool isEndDate, DateTimeOffset todaysDate, DayOfWeek weekStart, TimeZoneInfo timeZone) { var localToday = TimeZoneInfo.ConvertTime(todaysDate, timeZone); DateTimeOffset result; if (isEndDate) offset++; switch (magnitude) { case DateMagnitude.BusinessDay: var offsetMagn = Math.Abs(offset); var offsetSign = Math.Sign(offset); var i = 0; result = localToday; while (i < offsetMagn) { result = result.AddDays(offsetSign); if (result.DayOfWeek != DayOfWeek.Sunday && result.DayOfWeek != DayOfWeek.Saturday) i++; } break; case DateMagnitude.Week: result = GetWeekStart(todaysDate, weekStart).AddDays(offset * 7); break; case DateMagnitude.Month: result = new DateTimeOffset(todaysDate.Year, todaysDate.Month, 1, 0, 0, 0, localToday.Offset).AddMonths(offset); break; case DateMagnitude.Quarter: switch (todaysDate.Month) { case 1: case 2: case 3: result = new DateTimeOffset(todaysDate.Year, 1, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; case 4: case 5: case 6: result = new DateTimeOffset(todaysDate.Year, 4, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; case 7: case 8: case 9: result = new DateTimeOffset(todaysDate.Year, 7, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; default: result = new DateTimeOffset(todaysDate.Year, 10, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; } break; case DateMagnitude.Year: result = new DateTimeOffset(todaysDate.Year, 1, 1, 0, 0, 0, localToday.Offset).AddYears(offset * 3); break; default: result = todaysDate.AddDays(offset); break; } if (isEndDate) return result.Date.AddMilliseconds(-1); return result.Date; }
public PlaylistWindow(uint channelNumber, string channelCaption, TimeZoneInfo timezone) { InitializeComponent(); Title=channelCaption; this.channelNumber=channelNumber; this.timezone=timezone; this.Loaded+=Window_Loaded; }
/// <summary> /// Create a <see cref="CronCalendar" /> with the given cron expression and /// <see cref="BaseCalendar" />. /// </summary> /// <param name="baseCalendar"> /// the base calendar for this calendar instance /// see BaseCalendar for more information on base /// calendar functionality /// </param> /// <param name="expression">a String representation of the desired cron expression</param> /// <param name="timeZone"></param> public CronCalendar(ICalendar baseCalendar, string expression, TimeZone timeZone) : base(baseCalendar, timeZone) { cronExpression = new CronExpression(expression); }
public ISettableClock LocalNow(LocalTime time) { _timeZone = time.TimeZone; _time = time.UtcTime; return this; }
public ISettableClock LocalNow(DateTime now, TimeZoneInfo timeZone = null) { _timeZone = timeZone ?? TimeZoneInfo.Local; _time = now.ToUniversalTime(_timeZone); return this; }
public Time(Writer writer) : base("!time") { this.writer = writer; nz = TimeZoneInfo.FindSystemTimeZoneById("New Zealand Standard Time"); eu = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"); }
public static DateTimeAndZone FromUtc(DateTime utc, TimeZoneInfo timeZone) { if (utc.Kind == DateTimeKind.Local) throw new ArgumentException("DateTime utc must be .Kind == DateTimeKind.Utc, not Local.", "utc"); return new DateTimeAndZone(utc, timeZone); }
/// <summary> /// Gets a <see cref="DateTimeOffset"/> object that is set to the current date, time, /// and offset from Coordinated Universal Time (UTC) in the specified time zone. /// </summary> /// <param name="timeZoneInfo">The <see cref="TimeZoneInfo"/> instance.</param> /// <returns>The current <see cref="DateTimeOffset"/> for the specified time zone.</returns> public static DateTimeOffset NowInTimeZone(TimeZoneInfo timeZoneInfo) { // TODO: Propose placing this method directly in the System.DateTimeOffset struct DateTimeOffset utcNow = DateTimeOffset.UtcNow; return TimeZoneInfo.ConvertTime(utcNow, timeZoneInfo); }
public static Alarm ConvertToAlarm(this AlarmMessage alarmMessage, TimeZoneInfo timeZone, CultureInfo culture) { if (alarmMessage == null) throw new ArgumentNullException("alarmMessage"); return new Alarm(id: new Guid(alarmMessage.MessageDetails.AlarmGuid), description: alarmMessage.MessageDetails.Description, partitionId: Guid.Empty, partitionName: alarmMessage.MessageBase.PartitionName, isPublic: GetBoolFromStringInt(alarmMessage.MessageBase.IsPublic), messageDateTime: TimeZoneInfo.ConvertTime(DateTimeOffset.Parse(alarmMessage.MessageDetails.ConditionTimestampUtc, CultureInfo.InvariantCulture), timeZone), alarmTypeDescription: alarmMessage.MessageDetails.AlarmTypeName, category: alarmMessage.MessageBase.Category, priority: Convert.ToInt32(alarmMessage.MessageBase.Priority, CultureInfo.InvariantCulture), isResponseRequired: GetBoolFromStringInt(alarmMessage.MessageDetails.ResponseRequired), isAcknowledgeRequired: GetBoolFromStringInt(alarmMessage.MessageDetails.AcknowledgeRequired), alarmState: Convert.ToInt32(alarmMessage.MessageDetails.AlarmState, CultureInfo.CurrentCulture), alarmStateDescription: Translator.GetString(CategoryType.AlarmStates, Convert.ToInt32(alarmMessage.MessageDetails.AlarmState, CultureInfo.CurrentCulture), culture), stateDateTime: TimeZoneInfo.ConvertTime(DateTimeOffset.Parse(alarmMessage.MessageBase.TimestampUtc, CultureInfo.InvariantCulture), timeZone), conditionSequence: Convert.ToInt32(alarmMessage.MessageDetails.ConditionSequenceNumber, CultureInfo.InvariantCulture), site: alarmMessage.MessageBase.SiteName, sourceState: Convert.ToInt32(alarmMessage.MessageDetails.ConditionState, CultureInfo.CurrentCulture), sourceStateDescription: Translator.GetString(CategoryType.ConditionStates, Convert.ToInt32(alarmMessage.MessageDetails.ConditionState, CultureInfo.CurrentCulture), culture), escalation: Convert.ToInt32(alarmMessage.MessageBase.Escalation, CultureInfo.InvariantCulture), instructions: alarmMessage.MessageDetails.InstructionText, isPublicDescription: Translator.GetString(CategoryType.BooleanTypes, Convert.ToInt32(alarmMessage.MessageBase.IsPublic, CultureInfo.CurrentCulture), culture), isPending: alarmMessage.IsPending(), isCompletable: GetBoolFromStringInt(alarmMessage.MessageDetails.CanComplete), isRespondable: GetBoolFromStringInt(alarmMessage.MessageDetails.CanRespond), isRemovable: alarmMessage.IsRemovable(), isCompleted: alarmMessage.IsCompleted()); }
/// <summary> /// Adds a system time zone to the iCalendar. This time zone may /// then be used in date/time objects contained in the /// calendar. /// </summary> /// <param name="tzi">A System.TimeZoneInfo object to add to the calendar.</param> /// <returns>The time zone added to the calendar.</returns> public ITimeZone AddTimeZone(System.TimeZoneInfo tzi) { ITimeZone tz = iCalTimeZone.FromSystemTimeZone(tzi); this.AddChild(tz); return(tz); }
/// <summary> /// This functions determines if the TimeZone uses daylight saving time /// </summary> /// <param name="timezone">TimeZone instance to validate</param> /// <returns>True or false depending if daylight savings time is used</returns> public static bool UseDaylightTime(TimeZone timezone) { #if !NET_35 return(timezone.DaylightName != ""); #else return(timezone.SupportsDaylightSavingTime); #endif }
/// <summary> /// Translate a date and time from a users timezone to the another /// (probably server) timezone to assist in creating a simple trigger with /// the right date and time. /// </summary> /// <param name="date">the date to translate</param> /// <param name="src">the original time-zone</param> /// <param name="dest">the destination time-zone</param> /// <returns>the translated UTC date</returns> public static DateTime TranslateTime(DateTime date, TimeZone src, TimeZone dest) { DateTime newDate = DateTime.UtcNow; double offset = (GetOffset(date, dest) - GetOffset(date, src)); newDate = newDate.AddMilliseconds(-1 * offset); return(newDate); }
/// <summary> /// </summary> /// <param name="settings"></param> public SessionSchedule(QuickFix.Dictionary settings) { if (settings.Has(SessionSettings.NON_STOP_SESSION)) { NonStopSession = settings.GetBool(SessionSettings.NON_STOP_SESSION); } if (NonStopSession) { return; } if (!settings.Has(SessionSettings.START_DAY) && settings.Has(SessionSettings.END_DAY)) { throw new QuickFix.ConfigError("EndDay used without StartDay"); } if (settings.Has(SessionSettings.START_DAY) && !settings.Has(SessionSettings.END_DAY)) { throw new QuickFix.ConfigError("StartDay used without EndDay"); } if (settings.Has(SessionSettings.START_DAY) && settings.Has(SessionSettings.END_DAY)) { StartDay = settings.GetDay(SessionSettings.START_DAY); EndDay = settings.GetDay(SessionSettings.END_DAY); WeeklySession = true; } if (settings.Has(SessionSettings.USE_LOCAL_TIME)) { UseLocalTime = settings.GetBool(SessionSettings.USE_LOCAL_TIME); } if (settings.Has(SessionSettings.TIME_ZONE)) { if (UseLocalTime) { throw new ConfigError( SessionSettings.TIME_ZONE + " conflicts with " + SessionSettings.USE_LOCAL_TIME); } string id = settings.GetString(SessionSettings.TIME_ZONE); TimeZone = System.TimeZoneInfo.FindSystemTimeZoneById(id); } try { this.StartTime = System.TimeSpan.Parse( settings.GetString(SessionSettings.START_TIME)); this.EndTime = System.TimeSpan.Parse( settings.GetString(SessionSettings.END_TIME)); } catch (System.FormatException e) { throw new ConfigError(e.Message); } }
/// <summary> /// Gets the offset from UT for the given date in the given timezone, /// taking into account daylight savings. /// </summary> /// <param name="date">the date that is the base for the offset</param> /// <param name="tz">the time-zone to calculate to offset to</param> /// <returns>the offset</returns> public static double GetOffset(this DateTime date, TimeZone tz) { if (tz.IsDaylightSavingTime(date)) { // TODO return(tz.BaseUtcOffset.TotalMilliseconds + 0); } return(tz.BaseUtcOffset.TotalMilliseconds); }
/// <summary> /// Gets the offset from UT for the given date in the given timezone, /// taking into account daylight savings. /// </summary> /// <param name="date">the date that is the base for the offset</param> /// <param name="tz">the time-zone to calculate to offset to</param> /// <returns>the offset</returns> public static double GetOffset(DateTime date, TimeZone tz) { #if !NET_35 throw new Exception("UTC offset calculation not supported in < .NET 3.5"); #else if (tz.IsDaylightSavingTime(date)) { // TODO return(tz.BaseUtcOffset.TotalMilliseconds + 0); } return(tz.BaseUtcOffset.TotalMilliseconds); #endif }
public void TestCronTriggerTimeZone_TimeZoneShouldChangeWhenChanged() { string tzStr = "FLE Standard Time"; if (TimeZone.Local.Id == tzStr) { tzStr = "GMT Standard Time"; } TimeZone tz = TimeZone.FindSystemTimeZoneById(tzStr); CronTrigger trigger = new CronTrigger(); trigger.Name = "Quartz-579"; trigger.Group = SchedulerConstants.DefaultGroup; trigger.TimeZone = tz; trigger.CronExpressionString = "0 0 12 * * ?"; Assert.AreEqual(tz, trigger.TimeZone, "TimeZone was changed"); }
public bool analiseEspera(string diaA, string horaA, string minutoA, string taskA) { thisDay = DateTime.Today; timeUtc = DateTime.UtcNow; System.TimeZoneInfo brasilia = TimeZoneInfo.FindSystemTimeZoneById("Brazil/East"); hora = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, brasilia).ToString("HH"); minuto = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, brasilia).ToString("mm"); // Console.WriteLine($"dia {dia} | hora {hora} | minuto {minuto}"); int diaAI = int.Parse(diaA), horaAI = int.Parse(horaA), minutoAI = int.Parse(minutoA); if (diaAI == int.Parse(dia) & horaAI == int.Parse(hora) & minutoAI == int.Parse(minuto)) { Console.WriteLine(taskA); return(true); } return(false); }
public static iCalTimeZone FromSystemTimeZone(System.TimeZoneInfo tzinfo) { var adjustmentRules = tzinfo.GetAdjustmentRules(); var utcOffset = tzinfo.BaseUtcOffset; var dday_tz = new iCalTimeZone(); foreach (var adjustmentRule in adjustmentRules) { var delta = adjustmentRule.DaylightDelta; dday_tz.TZID = tzinfo.Id; var dday_tzinfo_standard = new DDay.iCal.Components.iCalTimeZoneInfo(); dday_tzinfo_standard.Name = "STANDARD"; dday_tzinfo_standard.Start = adjustmentRule.DateStart; if (dday_tzinfo_standard.Start.Year < 1800) { dday_tzinfo_standard.Start = dday_tzinfo_standard.Start.AddYears(1800 - dday_tzinfo_standard.Start.Year); } dday_tzinfo_standard.TZOffsetFrom = new DDay.iCal.DataTypes.UTC_Offset(utcOffset + delta); dday_tzinfo_standard.TZOffsetTo = new DDay.iCal.DataTypes.UTC_Offset(utcOffset); PopulateiCalTimeZoneInfo(dday_tzinfo_standard, adjustmentRule.DaylightTransitionEnd, adjustmentRule.DateStart.Year); // Add the "standard" time rule to the time zone dday_tz.AddChild(dday_tzinfo_standard); var dday_tzinfo_daylight = new DDay.iCal.Components.iCalTimeZoneInfo(); dday_tzinfo_daylight.Name = "DAYLIGHT"; dday_tzinfo_daylight.Start = adjustmentRule.DateStart; if (dday_tzinfo_daylight.Start.Year < 1800) { dday_tzinfo_daylight.Start = dday_tzinfo_daylight.Start.AddYears(1800 - dday_tzinfo_daylight.Start.Year); } dday_tzinfo_daylight.TZOffsetFrom = new DDay.iCal.DataTypes.UTC_Offset(utcOffset); dday_tzinfo_daylight.TZOffsetTo = new DDay.iCal.DataTypes.UTC_Offset(utcOffset + delta); PopulateiCalTimeZoneInfo(dday_tzinfo_daylight, adjustmentRule.DaylightTransitionStart, adjustmentRule.DateStart.Year); // Add the "daylight" time rule to the time zone dday_tz.AddChild(dday_tzinfo_daylight); } return(dday_tz); }
public void SystemTimeZone1() { System.TimeZoneInfo tzi = System.TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time"); Assert.IsNotNull(tzi); iCalendar iCal = new iCalendar(); iCalTimeZone tz = iCalTimeZone.FromSystemTimeZone(tzi); Assert.IsNotNull(tz); iCal.AddChild(tz); iCalDateTime dt1 = new iCalDateTime(2003, 10, 26, 0, 59, 59, tz.TZID, iCal); iCalDateTime dt2 = new iCalDateTime(2003, 10, 26, 1, 0, 0, tz.TZID, iCal); TimeSpan result = dt2 - dt1; Assert.AreEqual(TimeSpan.FromHours(1) + TimeSpan.FromSeconds(1), result); dt1 = new iCalDateTime(2004, 4, 4, 1, 59, 59, tz.TZID, iCal); dt2 = new iCalDateTime(2004, 4, 4, 2, 0, 0, tz.TZID, iCal); result = dt2 - dt1; Assert.AreEqual(TimeSpan.FromHours(-1) + TimeSpan.FromSeconds(1), result); }
public static iCalTimeZone FromSystemTimeZone(System.TimeZoneInfo tzinfo, DateTime earlistDateTimeToSupport, bool includeHistoricalData) { var adjustmentRules = tzinfo.GetAdjustmentRules(); var utcOffset = tzinfo.BaseUtcOffset; var dday_tz = new iCalTimeZone(); dday_tz.TZID = tzinfo.Id; IDateTime earliest = new iCalDateTime(earlistDateTimeToSupport); foreach (var adjustmentRule in adjustmentRules) { // Only include historical data if asked to do so. Otherwise, // use only the most recent adjustment rule available. if (!includeHistoricalData && adjustmentRule.DateEnd < earlistDateTimeToSupport) { continue; } var delta = adjustmentRule.DaylightDelta; var dday_tzinfo_standard = new DDay.iCal.iCalTimeZoneInfo(); dday_tzinfo_standard.Name = "STANDARD"; dday_tzinfo_standard.TimeZoneName = tzinfo.StandardName; dday_tzinfo_standard.Start = new iCalDateTime(new DateTime(adjustmentRule.DateStart.Year, adjustmentRule.DaylightTransitionEnd.Month, adjustmentRule.DaylightTransitionEnd.Day, adjustmentRule.DaylightTransitionEnd.TimeOfDay.Hour, adjustmentRule.DaylightTransitionEnd.TimeOfDay.Minute, adjustmentRule.DaylightTransitionEnd.TimeOfDay.Second).AddDays(1)); if (dday_tzinfo_standard.Start.LessThan(earliest)) { dday_tzinfo_standard.Start = dday_tzinfo_standard.Start.AddYears(earliest.Year - dday_tzinfo_standard.Start.Year); } dday_tzinfo_standard.OffsetFrom = new UTCOffset(utcOffset + delta); dday_tzinfo_standard.OffsetTo = new UTCOffset(utcOffset); PopulateiCalTimeZoneInfo(dday_tzinfo_standard, adjustmentRule.DaylightTransitionEnd, adjustmentRule.DateStart.Year); // Add the "standard" time rule to the time zone dday_tz.AddChild(dday_tzinfo_standard); if (tzinfo.SupportsDaylightSavingTime) { var dday_tzinfo_daylight = new DDay.iCal.iCalTimeZoneInfo(); dday_tzinfo_daylight.Name = "DAYLIGHT"; dday_tzinfo_daylight.TimeZoneName = tzinfo.DaylightName; dday_tzinfo_daylight.Start = new iCalDateTime(new DateTime(adjustmentRule.DateStart.Year, adjustmentRule.DaylightTransitionStart.Month, adjustmentRule.DaylightTransitionStart.Day, adjustmentRule.DaylightTransitionStart.TimeOfDay.Hour, adjustmentRule.DaylightTransitionStart.TimeOfDay.Minute, adjustmentRule.DaylightTransitionStart.TimeOfDay.Second)); if (dday_tzinfo_daylight.Start.LessThan(earliest)) { dday_tzinfo_daylight.Start = dday_tzinfo_daylight.Start.AddYears(earliest.Year - dday_tzinfo_daylight.Start.Year); } dday_tzinfo_daylight.OffsetFrom = new UTCOffset(utcOffset); dday_tzinfo_daylight.OffsetTo = new UTCOffset(utcOffset + delta); PopulateiCalTimeZoneInfo(dday_tzinfo_daylight, adjustmentRule.DaylightTransitionStart, adjustmentRule.DateStart.Year); // Add the "daylight" time rule to the time zone dday_tz.AddChild(dday_tzinfo_daylight); } } // If no time zone information was recorded, at least // add a STANDARD time zone element to indicate the // base time zone information. if (dday_tz.TimeZoneInfos.Count == 0) { var dday_tzinfo_standard = new DDay.iCal.iCalTimeZoneInfo(); dday_tzinfo_standard.Name = "STANDARD"; dday_tzinfo_standard.TimeZoneName = tzinfo.StandardName; dday_tzinfo_standard.Start = earliest; dday_tzinfo_standard.OffsetFrom = new UTCOffset(utcOffset); dday_tzinfo_standard.OffsetTo = new UTCOffset(utcOffset); // Add the "standard" time rule to the time zone dday_tz.AddChild(dday_tzinfo_standard); } return(dday_tz); }
public void TestTimeZone() { TimeZone GMT = TimeZone.FindSystemTimeZoneById("GMT Standard Time"); TimeZone EST = TimeZone.FindSystemTimeZoneById("Eastern Standard Time"); // Calendar startTime = Calendar.getInstance(EST); var startTime = new DateTime(2006, 3, 7, 7, 0, 0, DateTimeKind.Utc); startTime = TimeZone.ConvertTimeFromUtc(startTime, EST); // Same timezone { NthIncludedDayTrigger t = new NthIncludedDayTrigger("name", "group"); t.IntervalType = NthIncludedDayTrigger.IntervalTypeWeekly; t.N = 3; t.StartTimeUtc = startTime.ToUniversalTime(); t.FireAtTime = "8:00"; t.TimeZone = EST; DateTime?firstTime = t.ComputeFirstFireTimeUtc(null); // Calendar firstTimeCal = Calendar.getInstance(EST); DateTime firstTimeCal = new DateTime(startTime.Year, startTime.Month, startTime.Day, 8, 0, 0, 0, DateTimeKind.Utc); firstTimeCal = TimeZone.ConvertTimeFromUtc(firstTimeCal, EST); //roll start date forward to first day of the next week while (firstTimeCal.DayOfWeek != t.TriggerCalendarFirstDayOfWeek) { firstTimeCal = firstTimeCal.AddDays(-1); } //first day of the week counts as one. add two more to get N=3. firstTimeCal = firstTimeCal.AddDays(2); //if we went back too far, shift forward a week. if (firstTimeCal < startTime) { firstTimeCal = firstTimeCal.AddDays(7); } Assert.AreEqual(firstTime, firstTimeCal); } // Different timezones { NthIncludedDayTrigger t = new NthIncludedDayTrigger("name", "group"); t.IntervalType = NthIncludedDayTrigger.IntervalTypeWeekly; t.N = 3; t.StartTimeUtc = startTime; t.FireAtTime = "8:00"; t.TimeZone = GMT; DateTime?firstTime = t.ComputeFirstFireTimeUtc(null); // Calendar firstTimeCal = Calendar.getInstance(EST); DateTime firstTimeCal = new DateTime(startTime.Year, startTime.Month, startTime.Day, 8, 0, 0, 0); //EST is GMT-5 firstTimeCal.AddHours(-5); //roll start date forward to first day of the next week while (firstTimeCal.DayOfWeek != t.TriggerCalendarFirstDayOfWeek) { firstTimeCal = firstTimeCal.AddDays(-1); } //first day of the week counts as one. add two more to get N=3. firstTimeCal = firstTimeCal.AddDays(2); //if we went back too far, shift forward a week. if (firstTimeCal < startTime) { firstTimeCal = firstTimeCal.AddDays(7); } Assert.AreEqual(firstTime, firstTimeCal); } }
public static DateTime ToLocalDateTime(this long value, System.TimeZoneInfo tzi) { return(TimeZoneInfo.ConvertTimeFromUtc( new DateTime(value, DateTimeKind.Utc) , tzi)); }
public static iCalTimeZone FromSystemTimeZone(System.TimeZoneInfo tzinfo) { // Support date/times for January 1st of the previous year by default. return(FromSystemTimeZone(tzinfo, new DateTime(DateTime.Now.Year, 1, 1).AddYears(-1), false)); }
// Constructor internal CurrentSystemTimeZone() { LocalTimeZone = TimeZoneInfo.Local; }
public static DateTime ToTimeZone(this DateTime dateTime, TimeZoneInfo targetTimeZone) { return(TimeZoneInfo.ConvertTime(dateTime, targetTimeZone)); }
public Calinfo(TimeZoneInfo tzinfo) { this._tzinfo = tzinfo; }
/// <summary> /// This functions determines if the TimeZone uses daylight saving time /// </summary> /// <param name="timezone">TimeZone instance to validate</param> /// <returns>True or false depending if daylight savings time is used</returns> public static bool UseDaylightTime(this TimeZone timezone) { return(timezone.SupportsDaylightSavingTime); }
public void Populate() { #region Types of Keywords FieldPublicDynamic = new { PropPublic1 = "A", PropPublic2 = 1, PropPublic3 = "B", PropPublic4 = "B", PropPublic5 = "B", PropPublic6 = "B", PropPublic7 = "B", PropPublic8 = "B", PropPublic9 = "B", PropPublic10 = "B", PropPublic11 = "B", PropPublic12 = new { PropSubPublic1 = 0, PropSubPublic2 = 1, PropSubPublic3 = 2 } }; FieldPublicObject = new StringBuilder("Object - StringBuilder"); FieldPublicInt32 = int.MaxValue; FieldPublicInt64 = long.MaxValue; FieldPublicULong = ulong.MaxValue; FieldPublicUInt = uint.MaxValue; FieldPublicDecimal = 100000.999999m; FieldPublicDouble = 100000.999999d; FieldPublicChar = 'A'; FieldPublicByte = byte.MaxValue; FieldPublicBoolean = true; FieldPublicSByte = sbyte.MaxValue; FieldPublicShort = short.MaxValue; FieldPublicUShort = ushort.MaxValue; FieldPublicFloat = 100000.675555f; FieldPublicInt32Nullable = int.MaxValue; FieldPublicInt64Nullable = 2; FieldPublicULongNullable = ulong.MaxValue; FieldPublicUIntNullable = uint.MaxValue; FieldPublicDecimalNullable = 100000.999999m; FieldPublicDoubleNullable = 100000.999999d; FieldPublicCharNullable = 'A'; FieldPublicByteNullable = byte.MaxValue; FieldPublicBooleanNullable = true; FieldPublicSByteNullable = sbyte.MaxValue; FieldPublicShortNullable = short.MaxValue; FieldPublicUShortNullable = ushort.MaxValue; FieldPublicFloatNullable = 100000.675555f; #endregion #region System FieldPublicDateTime = new DateTime(2000, 1, 1, 1, 1, 1); FieldPublicTimeSpan = new TimeSpan(1, 10, 40); FieldPublicEnumDateTimeKind = DateTimeKind.Local; // Instantiate date and time using Persian calendar with years, // months, days, hours, minutes, seconds, and milliseconds FieldPublicDateTimeOffset = new DateTimeOffset(1387, 2, 12, 8, 6, 32, 545, new System.Globalization.PersianCalendar(), new TimeSpan(1, 0, 0)); FieldPublicIntPtr = new IntPtr(100); FieldPublicTimeZone = TimeZone.CurrentTimeZone; FieldPublicTimeZoneInfo = TimeZoneInfo.Utc; FieldPublicTuple = Tuple.Create <string, int, decimal>("T-string\"", 1, 1.1m); FieldPublicType = typeof(object); FieldPublicUIntPtr = new UIntPtr(100); FieldPublicUri = new Uri("http://www.site.com"); FieldPublicVersion = new Version(1, 0, 100, 1); FieldPublicGuid = new Guid("d5010f5b-0cd1-44ca-aacb-5678b9947e6c"); FieldPublicSingle = Single.MaxValue; FieldPublicException = new Exception("Test error", new Exception("inner exception")); FieldPublicEnumNonGeneric = EnumTest.ValueA; FieldPublicAction = () => true.Equals(true); FieldPublicAction2 = (a, b) => true.Equals(true); FieldPublicFunc = () => true; FieldPublicFunc2 = (a, b) => true; #endregion #region Arrays and Collections FieldPublicArrayUni = new string[2]; FieldPublicArrayUni[0] = "[0]"; FieldPublicArrayUni[1] = "[1]"; FieldPublicArrayTwo = new string[2, 2]; FieldPublicArrayTwo[0, 0] = "[0, 0]"; FieldPublicArrayTwo[0, 1] = "[0, 1]"; FieldPublicArrayTwo[1, 0] = "[1, 0]"; FieldPublicArrayTwo[1, 1] = "[1, 1]"; FieldPublicArrayThree = new string[1, 1, 2]; FieldPublicArrayThree[0, 0, 0] = "[0, 0, 0]"; FieldPublicArrayThree[0, 0, 1] = "[0, 0, 1]"; FieldPublicJaggedArrayTwo = new string[2][]; FieldPublicJaggedArrayTwo[0] = new string[5] { "a", "b", "c", "d", "e" }; FieldPublicJaggedArrayTwo[1] = new string[4] { "a1", "b1", "c1", "d1" }; FieldPublicJaggedArrayThree = new string[1][][]; FieldPublicJaggedArrayThree[0] = new string[1][]; FieldPublicJaggedArrayThree[0][0] = new string[2]; FieldPublicJaggedArrayThree[0][0][0] = "[0][0][0]"; FieldPublicJaggedArrayThree[0][0][1] = "[0][0][1]"; FieldPublicMixedArrayAndJagged = new int[3][, ] { new int[, ] { { 1, 3 }, { 5, 7 } }, new int[, ] { { 0, 2 }, { 4, 6 }, { 8, 10 } }, new int[, ] { { 11, 22 }, { 99, 88 }, { 0, 9 } } }; FieldPublicDictionary = new System.Collections.Generic.Dictionary <string, string>(); FieldPublicDictionary.Add("Key1", "Value1"); FieldPublicDictionary.Add("Key2", "Value2"); FieldPublicDictionary.Add("Key3", "Value3"); FieldPublicDictionary.Add("Key4", "Value4"); FieldPublicList = new System.Collections.Generic.List <int>(); FieldPublicList.Add(0); FieldPublicList.Add(1); FieldPublicList.Add(2); FieldPublicQueue = new System.Collections.Generic.Queue <int>(); FieldPublicQueue.Enqueue(10); FieldPublicQueue.Enqueue(11); FieldPublicQueue.Enqueue(12); FieldPublicHashSet = new System.Collections.Generic.HashSet <string>(); FieldPublicHashSet.Add("HashSet1"); FieldPublicHashSet.Add("HashSet2"); FieldPublicSortedSet = new System.Collections.Generic.SortedSet <string>(); FieldPublicSortedSet.Add("SortedSet1"); FieldPublicSortedSet.Add("SortedSet2"); FieldPublicSortedSet.Add("SortedSet3"); FieldPublicStack = new System.Collections.Generic.Stack <string>(); FieldPublicStack.Push("Stack1"); FieldPublicStack.Push("Stack2"); FieldPublicStack.Push("Stack3"); FieldPublicLinkedList = new System.Collections.Generic.LinkedList <string>(); FieldPublicLinkedList.AddFirst("LinkedList1"); FieldPublicLinkedList.AddLast("LinkedList2"); FieldPublicLinkedList.AddAfter(FieldPublicLinkedList.Find("LinkedList1"), "LinkedList1.1"); FieldPublicObservableCollection = new System.Collections.ObjectModel.ObservableCollection <string>(); FieldPublicObservableCollection.Add("ObservableCollection1"); FieldPublicObservableCollection.Add("ObservableCollection2"); FieldPublicKeyedCollection = new MyDataKeyedCollection(); FieldPublicKeyedCollection.Add(new MyData() { Data = "data1", Id = 0 }); FieldPublicKeyedCollection.Add(new MyData() { Data = "data2", Id = 1 }); var list = new List <string>(); list.Add("list1"); list.Add("list2"); list.Add("list3"); FieldPublicReadOnlyCollection = new ReadOnlyCollection <string>(list); FieldPublicReadOnlyDictionary = new ReadOnlyDictionary <string, string>(FieldPublicDictionary); FieldPublicReadOnlyObservableCollection = new ReadOnlyObservableCollection <string>(FieldPublicObservableCollection); FieldPublicCollection = new Collection <string>(); FieldPublicCollection.Add("collection1"); FieldPublicCollection.Add("collection2"); FieldPublicCollection.Add("collection3"); FieldPublicArrayListNonGeneric = new System.Collections.ArrayList(); FieldPublicArrayListNonGeneric.Add(1); FieldPublicArrayListNonGeneric.Add("a"); FieldPublicArrayListNonGeneric.Add(10.0m); FieldPublicArrayListNonGeneric.Add(new DateTime(2000, 01, 01)); FieldPublicBitArray = new System.Collections.BitArray(3); FieldPublicBitArray[2] = true; FieldPublicSortedList = new System.Collections.SortedList(); FieldPublicSortedList.Add("key1", 1); FieldPublicSortedList.Add("key2", 2); FieldPublicSortedList.Add("key3", 3); FieldPublicSortedList.Add("key4", 4); FieldPublicHashtableNonGeneric = new System.Collections.Hashtable(); FieldPublicHashtableNonGeneric.Add("key1", 1); FieldPublicHashtableNonGeneric.Add("key2", 2); FieldPublicHashtableNonGeneric.Add("key3", 3); FieldPublicHashtableNonGeneric.Add("key4", 4); FieldPublicQueueNonGeneric = new System.Collections.Queue(); FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric1"); FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric2"); FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric3"); FieldPublicStackNonGeneric = new System.Collections.Stack(); FieldPublicStackNonGeneric.Push("StackNonGeneric1"); FieldPublicStackNonGeneric.Push("StackNonGeneric2"); FieldPublicIEnumerable = FieldPublicSortedList; FieldPublicBlockingCollection = new System.Collections.Concurrent.BlockingCollection <string>(); FieldPublicBlockingCollection.Add("BlockingCollection1"); FieldPublicBlockingCollection.Add("BlockingCollection2"); FieldPublicConcurrentBag = new System.Collections.Concurrent.ConcurrentBag <string>(); FieldPublicConcurrentBag.Add("ConcurrentBag1"); FieldPublicConcurrentBag.Add("ConcurrentBag2"); FieldPublicConcurrentBag.Add("ConcurrentBag3"); FieldPublicConcurrentDictionary = new System.Collections.Concurrent.ConcurrentDictionary <string, int>(); FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary1", 0); FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary2", 0); FieldPublicConcurrentQueue = new System.Collections.Concurrent.ConcurrentQueue <string>(); FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue1"); FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue2"); FieldPublicConcurrentStack = new System.Collections.Concurrent.ConcurrentStack <string>(); FieldPublicConcurrentStack.Push("ConcurrentStack1"); FieldPublicConcurrentStack.Push("ConcurrentStack2"); // FieldPublicOrderablePartitioner = new OrderablePartitioner(); // FieldPublicPartitioner; // FieldPublicPartitionerNonGeneric; FieldPublicHybridDictionary = new System.Collections.Specialized.HybridDictionary(); FieldPublicHybridDictionary.Add("HybridDictionaryKey1", "HybridDictionary1"); FieldPublicHybridDictionary.Add("HybridDictionaryKey2", "HybridDictionary2"); FieldPublicListDictionary = new System.Collections.Specialized.ListDictionary(); FieldPublicListDictionary.Add("ListDictionaryKey1", "ListDictionary1"); FieldPublicListDictionary.Add("ListDictionaryKey2", "ListDictionary2"); FieldPublicNameValueCollection = new System.Collections.Specialized.NameValueCollection(); FieldPublicNameValueCollection.Add("Key1", "Value1"); FieldPublicNameValueCollection.Add("Key2", "Value2"); FieldPublicOrderedDictionary = new System.Collections.Specialized.OrderedDictionary(); FieldPublicOrderedDictionary.Add(1, "OrderedDictionary1"); FieldPublicOrderedDictionary.Add(2, "OrderedDictionary1"); FieldPublicOrderedDictionary.Add("OrderedDictionaryKey2", "OrderedDictionary2"); FieldPublicStringCollection = new System.Collections.Specialized.StringCollection(); FieldPublicStringCollection.Add("StringCollection1"); FieldPublicStringCollection.Add("StringCollection2"); #endregion #region Several PropXmlDocument = new XmlDocument(); PropXmlDocument.LoadXml("<xml>something</xml>"); var tr = new StringReader("<Root>Content</Root>"); PropXDocument = XDocument.Load(tr); PropStream = GenerateStreamFromString("Stream"); PropBigInteger = new System.Numerics.BigInteger(100); PropStringBuilder = new StringBuilder("StringBuilder"); FieldPublicIQueryable = new List <string>() { "IQueryable" }.AsQueryable(); #endregion #region Custom FieldPublicMyCollectionPublicGetEnumerator = new MyCollectionPublicGetEnumerator("a b c", new char[] { ' ' }); FieldPublicMyCollectionInheritsPublicGetEnumerator = new MyCollectionInheritsPublicGetEnumerator("a b c", new char[] { ' ' }); FieldPublicMyCollectionExplicitGetEnumerator = new MyCollectionExplicitGetEnumerator("a b c", new char[] { ' ' }); FieldPublicMyCollectionInheritsExplicitGetEnumerator = new MyCollectionInheritsExplicitGetEnumerator("a b c", new char[] { ' ' }); FieldPublicMyCollectionInheritsTooIEnumerable = new MyCollectionInheritsTooIEnumerable("a b c", new char[] { ' ' }); FieldPublicEnumSpecific = EnumTest.ValueB; MyDelegate = MethodDelegate; EmptyClass = new EmptyClass(); StructGeneric = new ThreeTuple <int>(0, 1, 2); StructGenericNullable = new ThreeTuple <int>(0, 1, 2); FieldPublicNullable = new Nullable <ThreeTuple <int> >(StructGeneric); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="BaseCalendar"/> class. /// </summary> /// <param name="timeZone">The time zone.</param> public BaseCalendar(TimeZone timeZone) { this.timeZone = timeZone; }
/// <summary> /// Initializes a new instance of the <see cref="BaseCalendar"/> class. /// </summary> /// <param name="baseCalendar">The base calendar.</param> /// <param name="timeZone">The time zone.</param> public BaseCalendar(ICalendar baseCalendar, TimeZone timeZone) { this.baseCalendar = baseCalendar; this.timeZone = timeZone; }
public EventStore(Calinfo calinfo) { this.id = calinfo.id; this.tzinfo = calinfo.tzinfo; }
/* * public Dictionary<string, string> metadict * { get { return _metadict; } } * private Dictionary<string, string> _metadict; */ public Calinfo(string id) { this.timestamp = DateTime.UtcNow; var metadict = Metadata.LoadMetadataForIdFromAzureTable(id); try { this._id = id; if (metadict.ContainsKey("type") == false) { GenUtils.PriorityLogMsg("exception", "new calinfo: no hub type for id (" + id + ")", null); return; } this._contact = Configurator.GetStrSetting(metadict, Configurator.usersettings, "contact"); this._css = Configurator.GetUriSetting(metadict, Configurator.usersettings, "css").ToString(); this._default_image_html = Configurator.GetStrSetting(metadict, Configurator.usersettings, "default_img_html"); //this._has_descriptions = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "descriptions"); this._has_descriptions = true; //this._has_locations = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "locations"); this._has_locations = true; this._display_width = Configurator.GetStrSetting(metadict, Configurator.usersettings, "display_width"); // todo: obsolete this this._feed_count = Configurator.GetMetadictValueOrSettingsValue(metadict, Configurator.usersettings, "feed_count"); this._has_img = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "header_image"); this._icalendar_horizon_days = Configurator.GetIntSetting(metadict, Configurator.usersettings, "icalendar_horizon_days"); this._img_url = Configurator.GetUriSetting(metadict, Configurator.usersettings, "img"); this._title = Configurator.GetTitleSetting(metadict, Configurator.usersettings, "title"); this._template_url = Configurator.GetUriSetting(metadict, Configurator.usersettings, "template"); //this._template_url = new Uri(Configurator.settings["template"]); this._twitter_account = Configurator.GetStrSetting(metadict, Configurator.usersettings, "twitter"); this._tzname = Configurator.GetStrSetting(metadict, Configurator.usersettings, "tz"); this._tzinfo = Utils.TzinfoFromName(this._tzname); this._use_rdfa = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "use_rdfa"); this._use_x_wr_timezone = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "use_x_wr_timezone"); //if (metadict.ContainsKey("where")) if (metadict["type"] == "where") { this._hub_enum = HubType.where; this._where = metadict[this.hub_enum.ToString()]; this._what = Configurator.nothing; //this._radius = metadict.ContainsKey("radius") ? Convert.ToInt16(metadict["radius"]) : Configurator.default_radius; this._radius = Configurator.GetIntSetting(metadict, Configurator.usersettings, "radius"); // enforce the default max radius if (this._radius > Configurator.max_radius) { this._radius = Configurator.max_radius; } this._population = Configurator.GetPopSetting(this.id, metadict, Configurator.usersettings, "population"); this._eventful = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "eventful"); this._eventbrite = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "eventbrite"); this._facebook = Configurator.GetBoolSetting(metadict, Configurator.usersettings, "facebook"); // curator gets to override the lat/lon that will otherwise be looked up based on the location // if (!metadict.ContainsKey("lat") && !metadict.ContainsKey("lon")) if (GenUtils.KeyExistsAndHasValue(metadict, "lat") && GenUtils.KeyExistsAndHasValue(metadict, "lon")) { this._lat = metadict["lat"]; this._lon = metadict["lon"]; } else { var apikeys = new Apikeys(); var lookup_lat = Utils.LookupLatLon(apikeys.bing_maps_key, this.where)[0]; var lookup_lon = Utils.LookupLatLon(apikeys.bing_maps_key, this.where)[1]; if (!String.IsNullOrEmpty(lookup_lat) && !String.IsNullOrEmpty(lookup_lon)) { this._lat = metadict["lat"] = lookup_lat; this._lon = metadict["lon"] = lookup_lon; Utils.UpdateLatLonToAzureForId(id, lookup_lat, lookup_lon); } } if (String.IsNullOrEmpty(this.lat) && String.IsNullOrEmpty(this.lon)) { GenUtils.PriorityLogMsg("warning", "Configurator: no lat and/or lon for " + id, null); } this.SetShowBadgesForHub(); } // if (metadict.ContainsKey("what")) if (metadict["type"] == "what") { this._hub_enum = HubType.what; this._what = metadict[this.hub_enum.ToString()]; this._where = Configurator.nowhere; this.SetShowBadgesForHub(); } if (metadict["type"] == "region") { this._hub_enum = HubType.region; this._what = Configurator.nothing; this._where = Configurator.nowhere; this.SetShowBadgesForRegion(); } } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "new Calinfo: " + id, e.Message + e.StackTrace); } }