本文整理汇总了C#中System.TimeZone类的典型用法代码示例。如果您正苦于以下问题:C# TimeZone类的具体用法?C# TimeZone怎么用?C# TimeZone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeZone类属于System命名空间,在下文中一共展示了TimeZone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Gregorian
internal Gregorian(Time time, TimeZone timezone)
{
this.time = time;
if (timezone == null)
timezone = time.Context.Gmt ();
this.timezone = timezone;
}
示例2: ResetTimeZone
//This method is called by CultureInfo.ClearCachedData in response to control panel
//change events. It must be synchronized because otherwise there is a race condition
//with the CurrentTimeZone property above.
internal static void ResetTimeZone() {
if (currentTimeZone!=null) {
lock(InternalSyncObject) {
currentTimeZone = null;
}
}
}
示例3: ResetTimeZone
//This method is called by CultureInfo.ClearCachedData in response to control panel
//change events. It must be synchronized because otherwise there is a race condition
//with the CurrentTimeZone property above.
internal static void ResetTimeZone() {
if (currentTimeZone!=null) {
lock(typeof(TimeZone)) {
currentTimeZone = null;
}
}
}
示例4: CET
private void CET (TimeZone t1)
{
AssertEquals("A01", "CET", t1.StandardName);
AssertEquals("A02", "CEST", t1.DaylightName);
DaylightTime d1 = t1.GetDaylightChanges (2002);
AssertEquals("A03", "03/31/2002 01:00:00", d1.Start.ToString ("G"));
AssertEquals("A04", "10/27/2002 01:00:00", d1.End.ToString ("G"));
AssertEquals("A05", 36000000000L, d1.Delta.Ticks);
DaylightTime d2 = t1.GetDaylightChanges (1996);
AssertEquals("A06", "03/31/1996 01:00:00", d2.Start.ToString ("G"));
AssertEquals("A07", "10/27/1996 01:00:00", d2.End.ToString ("G"));
AssertEquals("A08", 36000000000L, d2.Delta.Ticks);
DateTime d3 = new DateTime (2002,2,25);
AssertEquals("A09", false, t1.IsDaylightSavingTime (d3));
DateTime d4 = new DateTime (2002,4,2);
AssertEquals("A10", true, t1.IsDaylightSavingTime (d4));
DateTime d5 = new DateTime (2002,11,4);
AssertEquals("A11", false, t1.IsDaylightSavingTime (d5));
AssertEquals("A12", 36000000000L, t1.GetUtcOffset (d3).Ticks);
AssertEquals("A13", 72000000000L, t1.GetUtcOffset (d4).Ticks);
AssertEquals("A14", 36000000000L, t1.GetUtcOffset (d5).Ticks);
}
示例5: EST
private void EST (TimeZone t1)
{
// It could be EST though...
//Assert.AreEqual("Eastern Standard Time", t1.StandardName, "B01");
//Assert.AreEqual("Eastern Daylight Time", t1.DaylightName, "B02");
DaylightTime d1 = t1.GetDaylightChanges (2002);
Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G"), "B03");
Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G"), "B04");
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05");
DaylightTime d2 = t1.GetDaylightChanges (1996);
Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString ("G"), "B06");
Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G"), "B07");
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08");
DateTime d3 = new DateTime (2002,2,25);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "B09");
DateTime d4 = new DateTime (2002,4,8);
Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "B10");
DateTime d5 = new DateTime (2002,11,4);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "B11");
Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d3).Ticks, "B12");
Assert.AreEqual(-144000000000L, t1.GetUtcOffset (d4).Ticks, "B13");
Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d5).Ticks, "B14");
}
示例6: CET
private void CET (TimeZone t1)
{
Assert.AreEqual("CET", t1.StandardName, "A01");
Assert.AreEqual("CEST", t1.DaylightName, "A02");
DaylightTime d1 = t1.GetDaylightChanges (2002);
Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G"), "A03");
Assert.AreEqual("10/27/2002 03:00:00", d1.End.ToString ("G"), "A04");
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "A05");
DaylightTime d2 = t1.GetDaylightChanges (1996);
Assert.AreEqual("03/31/1996 02:00:00", d2.Start.ToString ("G"), "A06");
Assert.AreEqual("10/27/1996 03:00:00", d2.End.ToString ("G"), "A07");
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "A08");
DateTime d3 = new DateTime (2002,2,25);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "A09");
DateTime d4 = new DateTime (2002,4,2);
Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "A10");
DateTime d5 = new DateTime (2002,11,4);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "A11");
Assert.AreEqual(36000000000L, t1.GetUtcOffset (d3).Ticks, "A12");
Assert.AreEqual(72000000000L, t1.GetUtcOffset (d4).Ticks, "A13");
Assert.AreEqual(36000000000L, t1.GetUtcOffset (d5).Ticks, "A14");
}
示例7: AConnectorBase
public AConnectorBase()
{
this.hubSpotAPIKey = UConfig.getAppConfigValue("HubSpotAPIKey", bool.Parse(UConfig.getAppConfigValue("EncryptedCredentials", false)));
this.connectionString = UConfig.getAppConfigValue("SQLConnectionString", bool.Parse(UConfig.getAppConfigValue("EncryptedCredentials", false)));
//***** MHM Contacts – Replaced *****//
//this.hubSpotAPIUrl = UConfig.getAppConfigValue("HubSpotURL", false) + hubSpotAPIKey;
if (UConfig.getAppConfigValue("HubSpotContact", false) == "true")
this.hubSpotAPIUrl = UConfig.getAppConfigValue("HubSpotContactURL", false) + hubSpotAPIKey;
else
this.hubSpotAPIUrl = UConfig.getAppConfigValue("HubSpotURL", false) + hubSpotAPIKey;
//***** MHM Contacts ****************//
this.hubSpotAPIVersion = UConfig.getAppConfigValue("HubSpotAPIVersion", false).ToLower();
this.databaseVersion = AppGlobal.getDatabaseVersion(UConfig.getAppConfigValue("DatabaseVersion", false));
this.sqlConnection = new SqlConnection(connectionString);
this.debugLogPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\OLD_Log.txt";
this.dataMaps = new Hashtable();
this.pushPullDateTimeFormat = AppGlobal.getPushPullDateTimeFormat();
this.timeZone = AppGlobal.getCurrentTimeZone();
this.hubSpotMaps = new Hashtable();
this.endpoint = new HubSpotEndpoint(hubSpotAPIVersion, hubSpotAPIKey);
this.hubSpotTimePivot = UConfig.getAppConfigValue("HubSpotTimePivot", false);
this.sqlBatchSize = UConfig.getAppConfigValue("SQLBatchSize", false);
int batchSize; // need to make sure that sqlBatchSize is a valid integer
if (Int32.TryParse(sqlBatchSize, out batchSize) == false)
{
sqlBatchSize = "0";
}
loadDataMaps();
}
示例8: EST
private void EST (TimeZone t1)
{
Assert.IsTrue("EST" == t1.StandardName || "Eastern Standard Time" == t1.StandardName, "B01");
Assert.IsTrue("EDT" == t1.DaylightName || "Eastern Daylight Time" == t1.DaylightName, "B02");
DaylightTime d1 = t1.GetDaylightChanges (2002);
Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "B03");
Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "B04");
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05");
DaylightTime d2 = t1.GetDaylightChanges (1996);
Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "B06");
Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "B07");
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08");
DateTime d3 = new DateTime (2002,2,25);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "B09");
DateTime d4 = new DateTime (2002,4,8);
Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "B10");
DateTime d5 = new DateTime (2002,11,4);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "B11");
Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d3).Ticks, "B12");
Assert.AreEqual(-144000000000L, t1.GetUtcOffset (d4).Ticks, "B13");
Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d5).Ticks, "B14");
// Test TimeZone methods with UTC DateTime in DST.
DateTime d6 = d4.ToUniversalTime ();
Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "B15");
Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "B16");
}
示例9: PSSenderInfo
private PSSenderInfo(SerializationInfo info, StreamingContext context)
{
if (info != null)
{
string source = null;
try
{
source = info.GetValue("CliXml", typeof(string)) as string;
}
catch (Exception)
{
return;
}
if (source != null)
{
try
{
PSSenderInfo info2 = DeserializingTypeConverter.RehydratePSSenderInfo(PSObject.AsPSObject(PSSerializer.Deserialize(source)));
this.userPrinicpal = info2.userPrinicpal;
this.clientTimeZone = info2.ClientTimeZone;
this.connectionString = info2.connectionString;
this.applicationArguments = info2.applicationArguments;
}
catch (Exception)
{
return;
}
}
}
}
示例10: CET
private void CET (TimeZone t1)
{
Assert.AreEqual("CET", t1.StandardName, "A01");
Assert.AreEqual("CEST", t1.DaylightName, "A02");
DaylightTime d1 = t1.GetDaylightChanges (2002);
Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "A03");
Assert.AreEqual("10/27/2002 03:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "A04");
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "A05");
DaylightTime d2 = t1.GetDaylightChanges (1996);
Assert.AreEqual("03/31/1996 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "A06");
Assert.AreEqual("10/27/1996 03:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "A07");
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "A08");
DateTime d3 = new DateTime (2002,2,25);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "A09");
DateTime d4 = new DateTime (2002,4,2);
Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "A10");
DateTime d5 = new DateTime (2002,11,4);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "A11");
Assert.AreEqual(36000000000L, t1.GetUtcOffset (d3).Ticks, "A12");
Assert.AreEqual(72000000000L, t1.GetUtcOffset (d4).Ticks, "A13");
Assert.AreEqual(36000000000L, t1.GetUtcOffset (d5).Ticks, "A14");
// Test TimeZone methods with UTC DateTime in DST.
DateTime d6 = d4.ToUniversalTime ();
Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "A15");
Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "A16");
}
示例11: DateTimeConverter
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();
}
}
示例12: TestDateTimeFactory
private TestDateTimeFactory(DateTime seedTime, double acceleration, TimeSpan increment)
{
this.seedTime = seedTime.Add(new TimeSpan(-increment.Ticks)).ToUniversalTime();
this.ticksLastCall = 0;
this.acceleration = acceleration;
this.increment = increment;
this.currentTimeZone = TimeZone.CurrentTimeZone;
}
示例13: GetTimestamp
public long GetTimestamp(int startOfCentury, TimeZone timeZone)
{
var century = startOfCentury/100*100;
if (value[6] < startOfCentury%100)
{
century += 100;
}
return -1;
}
示例14: RangeTime
public void RangeTime()
{
var timeZone = new TimeZone("Default");
timeZone.AddRangeTime(DayOfWeek.Monday, 9, 10);
Assert.AreEqual(1, timeZone.WorkingDays.Count());
var workingDay = timeZone.WorkingDays.FirstOrDefault();
Assert.AreEqual(2, workingDay.WorkingHours.Count());
timeZone.AddRangeTime(DayOfWeek.Monday, 9, 10);
Assert.AreEqual(1, timeZone.WorkingDays.Count());
workingDay = timeZone.WorkingDays.FirstOrDefault();
Assert.AreEqual(2, workingDay.WorkingHours.Count());
}
示例15: TST
private void TST (TimeZone t1)
{
Assert.AreEqual("Tokyo Standard Time", t1.StandardName, "C01");
Assert.AreEqual("Tokyo Standard Time", t1.DaylightName, "C02");
DateTime d3 = new DateTime (2002,2,25);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "C09");
DateTime d4 = new DateTime (2002,4,8);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d4), "C10");
DateTime d5 = new DateTime (2002,11,4);
Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "C11");
Assert.AreEqual(324000000000L, t1.GetUtcOffset (d3).Ticks, "C12");
Assert.AreEqual(324000000000L, t1.GetUtcOffset (d4).Ticks, "C13");
Assert.AreEqual(324000000000L, t1.GetUtcOffset (d5).Ticks, "C14");
}