public static DateTimeAndZone FromUtcAndTimeZoneId(DateTime utc, TimeZoneId timeZoneId) { if (utc.Kind == DateTimeKind.Local) throw new ArgumentException("DateTime utc must be .Kind == DateTimeKind.Utc, not Local.", "utc"); return FromUtc(utc, TimeZoneIdMap.Current.FindSystemTimeZoneById(timeZoneId)); }
internal StockExchangeTimeZoneData(StockExchangeID p_stockExchangeID, CountryID p_countryID, TimeZoneId p_timeZoneID, TimeZoneInfo p_timeZoneInfo) { StockExchangeID = p_stockExchangeID; CountryID = p_countryID; TimeZoneID = p_timeZoneID; TimeZoneInfo = p_timeZoneInfo; }
protected string generalShortName(TimeZoneId tzId) { string standard = TimeZoneShortNameMap.Current.StandardNameForTimeZoneId(tzId); string daylight = TimeZoneShortNameMap.Current.DaylightNameForTimeZoneId(tzId); string general = standard + (daylight != null ? "/" + daylight : ""); return general; }
/// <summary> /// Returns a TimeZone object for a supplied time zone identifier. /// </summary> /// <param name="tzId"> /// Time zone identifier. /// Currently the only supported time zone ID is Microsoft.SPOT.TimeZoneId.London. /// </param> /// <returns>a TimeZone object for the supplied time zone identifier.</returns> /// <exception cref="NotImplementedException"> /// TimeZone identifier not supported. /// The current implementation supports only Microsoft.SPOT.TimeZoneId.London. /// </exception> public static TimeZone Create(TimeZoneId tzId) { switch (tzId) { case TimeZoneId.London: return new TimeZone_Uk(); default: throw new NotImplementedException("Time zone not supported"); } }
protected void mapTimeZoneIdAndShortName(TimeZoneId timeZoneId, string shortStandard, string shortDaylight) { shortNameToTimeZoneId.Add(shortStandard, timeZoneId); timeZoneIdToStandardShortName.Add(timeZoneId, shortStandard); if (shortDaylight != null) { shortNameToTimeZoneId.Add(shortDaylight, timeZoneId); timeZoneIdToDaylightShortName.Add(timeZoneId, shortDaylight); } }
//http://www.mcnearney.net/blog/windows-timezoneinfo-olson-mapping/ //http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml //string londonZoneId = "GMT Standard Time"; // Linux: "Europe/London" // http://mono.1490590.n4.nabble.com/Cross-platform-time-zones-td1507630.html //In windows the timezones have a descriptive name such as "Eastern //Standard Time" but in linux the same timezone has the name //"US/Eastern". //Is there a cross platform way of running //TimeZoneInfo.FindSystemTimeZoneById that can be used both in linux and //windows, or would i have to add additional code to check what platform //i am running before getting the time zone. //WINDOWS TIMEZONE ID DESCRIPTION UNIX TIMEZONE ID //Eastern Standard Time => GMT - 5 w/DST => US/Eastern //Central Standard Time => GMT - 6 w/DST => US/Central //US Central Standard Time => GMT-6 w/o DST(Indiana) => US / Indiana - Stark //Mountain Standard Time => GMT-7 w/DST => US/Mountain //US Mountain Standard Time => GMT-7 w/o DST(Arizona) => US / Arizona //Pacific Standard Time => GMT-8 w/DST => US/Pacific //Alaskan Standard Time => GMT - 9 w/DST => US/Alaska //Hawaiian Standard Time => GMT - 10 w/DST => US/Hawaii public static TimeZoneInfo FindSystemTimeZoneById(TimeZoneId p_tzType) { switch (p_tzType) { case TimeZoneId.UTC: return TimeZoneInfo.Utc; default: TimeZoneInfo tzi = null; if (g_tzi.TryGetValue(p_tzType, out tzi)) return tzi; string zoneId; switch (p_tzType) { case TimeZoneId.London: if (Utils.RunningPlatform() == Platform.Windows) zoneId = "GMT Standard Time"; else zoneId = "Europe/London"; break; case TimeZoneId.EST: if (Utils.RunningPlatform() == Platform.Windows) zoneId = "Eastern Standard Time"; else zoneId = "America/New_York"; // or "US/Eastern". We have to test it. break; case TimeZoneId.CET: if (Utils.RunningPlatform() == Platform.Windows) zoneId = "Central Europe Standard Time"; else zoneId = "Europe/Budapest"; break; default: throw new Exception($"TimeZoneType {p_tzType} is unexpected."); } try { tzi = TimeZoneInfo.FindSystemTimeZoneById(zoneId); } catch (Exception e) { Utils.Logger.Error("ERROR: Unable to find the {0} zone in the registry. {1}", zoneId, e.Message); } g_tzi[p_tzType] = tzi; return tzi; } }
public DateTime ToLocal(TimeZoneId timeZoneId) { return ToLocal(TimeZoneIdMap.Current.FindSystemTimeZoneById(timeZoneId)); }
public void SwitchTimeZone(TimeZoneId timeZoneId) { SwitchTimeZone(TimeZoneIdMap.Current.FindSystemTimeZoneById(timeZoneId)); }
public static DateTimeAndZone FromLocalAndTimeZoneId(DateTime local, TimeZoneId timeZoneId) { if (local.Kind == DateTimeKind.Utc) throw new ArgumentException("DateTime utc must be .Kind == DateTimeKind.Local, not Utc.", "local"); return FromLocal(local, TimeZoneIdMap.Current.FindSystemTimeZoneById(timeZoneId)); }
public string DaylightNameForTimeZoneId(TimeZoneId timeZoneId) { string daylight = null; timeZoneIdToDaylightShortName.TryGetValue(timeZoneId, out daylight); return daylight; }
public string IdToString(TimeZoneId timeZoneId) { return enumToString[timeZoneId]; }
public string StandardNameForTimeZoneId(TimeZoneId timeZoneId) { return(timeZoneIdToStandardShortName[timeZoneId]); }
public static string GetRegistryKeyNameByTimeZoneId(TimeZoneId id) { foreach (string key in timeZoneIdTable.Keys) if (timeZoneIdTable[key] == id) return key; return String.Empty; }
public List <ActionObjectPath> GetRequest(IIdProvider idProvider) { int createSiteId = idProvider.GetActionId(); IdentityPath = idProvider.GetActionId(); QueryIdPath = idProvider.GetActionId(); #region XML Payload generated /* * <Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="pnp core sdk" * xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"> * <Actions> * <Query Id="3" ObjectPathId="1"> * <Query SelectAllProperties="false"> * <Properties> * <Property Name="PollingInterval" ScalarProperty="true" /> * <Property Name="IsComplete" ScalarProperty="true" /> * </Properties> * </Query> * </Query> * </Actions> * <ObjectPaths> * <Constructor Id="2" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /> * <Method Id="1" ParentId="2" Name="CreateSite"> * <Parameters> * <Parameter TypeId="{11f84fff-b8cf-47b6-8b50-34e692656606}"> * <Property Name="CompatibilityLevel" Type="Int32">0</Property> * <Property Name="Lcid" Type="Int32">1033</Property> * <Property Name="Owner" Type="String">[email protected]</Property> * <Property Name="StorageMaximumLevel" Type="Int64">27487790694400</Property> * <Property Name="StorageWarningLevel" Type="Int64">27487790694400</Property> * <Property Name="Template" Type="String">STS#0</Property> * <Property Name="TimeZoneId" Type="Int32">3</Property> * <Property Name="Title" Type="String">PnP Core SDK Test</Property> * <Property Name="Url" Type="String">https://bertonline.sharepoint.com/sites/pnpcoresdktestclassicsitef03a62586d3e41658f8ad2ceb7e53acf</Property> * <Property Name="UserCodeMaximumLevel" Type="Double">0</Property> * <Property Name="UserCodeWarningLevel" Type="Double">0</Property> * </Parameter> * </Parameters> * </Method> * </ObjectPaths> * </Request> */ #endregion List <ActionObjectPath> actions = new List <ActionObjectPath>(); ActionObjectPath spoOperation = new ActionObjectPath() { Action = new QueryAction() { Id = QueryIdPath, ObjectPathId = createSiteId.ToString(), SelectQuery = new SelectQuery() { SelectAllProperties = false, Properties = new List <Property>() { new Property() { Name = "PollingInterval" }, new Property() { Name = "IsComplete" }, } } } }; ActionObjectPath createSiteAction = new ActionObjectPath() { ObjectPath = new ObjectPathMethod() { Id = createSiteId, ParentId = IdentityPath, Name = "CreateSite", Parameters = new MethodParameter() { Properties = new List <Parameter>() { new Parameter() { TypeId = "11f84fff-b8cf-47b6-8b50-34e692656606", Value = new List <NamedProperty>() { new NamedProperty() { Name = "CompatibilityLevel", Type = "Int32", Value = "0" }, new NamedProperty() { Name = "Lcid", Type = "Int32", Value = Lcid.ToString() }, new NamedProperty() { Name = "Owner", Type = "String", Value = Owner }, new NamedProperty() { Name = "StorageMaximumLevel", Type = "Int64", Value = "27487790694400" }, new NamedProperty() { Name = "StorageWarningLevel", Type = "Int64", Value = "27487790694400" }, new NamedProperty() { Name = "Template", Type = "String", Value = WebTemplate }, new NamedProperty() { Name = "TimeZoneId", Type = "Int32", Value = TimeZoneId.ToString() }, new NamedProperty() { Name = "Title", Type = "String", Value = Title }, new NamedProperty() { Name = "Url", Type = "String", Value = SiteUrl.AbsoluteUri.ToString() }, new NamedProperty() { Name = "UserCodeMaximumLevel", Type = "Double", Value = "0" }, new NamedProperty() { Name = "UserCodeWarningLevel", Type = "Double", Value = "0" }, } } } } } }; ActionObjectPath spoOperationCollection = new ActionObjectPath() { ObjectPath = new ConstructorPath { Id = IdentityPath, TypeId = PnPAdminConstants.CsomTenantObject } }; actions.Add(spoOperation); actions.Add(spoOperationCollection); actions.Add(createSiteAction); return(actions); }
public DateTimeAndZone GetUtcTimeZone(DateTime local, string state, string country, TimeZoneId defaultTimeZoneId) { var timeZone = GetTimeZoneInfo(state, country, defaultTimeZoneId); return(DateTimeAndZone.FromLocal(local, timeZone)); }
public override int GetHashCode() { return(CityName.GetHashCode() ^ TimeZoneId.GetHashCode()); }
public string StandardNameForTimeZoneId(TimeZoneId timeZoneId) { return timeZoneIdToStandardShortName[timeZoneId]; }
public TimeZoneInfo FindSystemTimeZoneById(TimeZoneId timeZoneID) { return TimeZoneInfo.FindSystemTimeZoneById(IdToString(timeZoneID)); }
protected void mapTimeZoneIdAndShortName(TimeZoneId timeZoneId, string shortStandard) { mapTimeZoneIdAndShortName(timeZoneId, shortStandard, null); }
public TimeZoneInfo GetTimeZoneInfo(string state, string country, TimeZoneId defaultTimeZoneId) { var timeZoneId = GetTimeZoneId(state, country); if (timeZoneId == TimeZoneId.None) { if (defaultTimeZoneId == TimeZoneId.None) return null; timeZoneId = defaultTimeZoneId; } return TimeZoneInfo.FindSystemTimeZoneById(TimeZoneIdMap.Current.IdToString(timeZoneId)); }
public string ShortNameForTime(DateTime utc, TimeZoneId timeZoneId) { return ShortNameForTime(utc, TimeZoneIdMap.Current.FindSystemTimeZoneById(timeZoneId)); }
public DateTimeAndZone GetUtcTimeZone(DateTime local, string state, string country, TimeZoneId defaultTimeZoneId) { var timeZone = GetTimeZoneInfo(state, country, defaultTimeZoneId); return DateTimeAndZone.FromLocal(local, timeZone); }