当前位置: 首页>>代码示例>>C#>>正文


C# TimeZone.GetUtcOffset方法代码示例

本文整理汇总了C#中System.TimeZone.GetUtcOffset方法的典型用法代码示例。如果您正苦于以下问题:C# TimeZone.GetUtcOffset方法的具体用法?C# TimeZone.GetUtcOffset怎么用?C# TimeZone.GetUtcOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.TimeZone的用法示例。


在下文中一共展示了TimeZone.GetUtcOffset方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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");
	}
开发者ID:mpareja,项目名称:mono,代码行数:27,代码来源:TimeZoneTest.cs

示例2: 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");
	}
开发者ID:caomw,项目名称:mono,代码行数:31,代码来源:TimeZoneTest.cs

示例3: 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");
	}
开发者ID:mpareja,项目名称:mono,代码行数:26,代码来源:TimeZoneTest.cs

示例4: 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");
	}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:32,代码来源:TimeZoneTest.cs

示例5: 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);
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:26,代码来源:TimeZoneTest.cs

示例6: ServerInfo

 public ServerInfo( string name, int fullPercent, TimeZone tz, IPEndPoint address )
 {
     m_Name = name;
     m_FullPercent = fullPercent;
     m_TimeZone = tz.GetUtcOffset( Core.Now ).Hours;
     m_Address = address;
 }
开发者ID:BackupTheBerlios,项目名称:sunuo-svn,代码行数:7,代码来源:Packets.cs

示例7: GMT

	private void GMT (TimeZone t1) {
		// Probably wont work on MS.NET, but is better than nothing. Where do
		// we change our implementation to match theirs?
		
		Assert.AreEqual("GMT", t1.StandardName, "D01");
		Assert.IsTrue("BST" == t1.DaylightName || "IST" == t1.DaylightName, "D02");
	
		DaylightTime d1 = t1.GetDaylightChanges (2002);
		Assert.AreEqual("03/31/2002 01:00:00", d1.Start.ToString ("G"), "D03");
		Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G"), "D04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "D05");
	
		DaylightTime d2 = t1.GetDaylightChanges (1996);
		Assert.AreEqual("03/31/1996 01:00:00", d2.Start.ToString ("G"), "D06");
		Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G"), "D07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "D08");
	
		DateTime d3 = new DateTime (2002,2,25);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "D09");
		DateTime d4 = new DateTime (2002,4,2);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "D10");
		DateTime d5 = new DateTime (2002,11,4);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "D11");
	
		Assert.AreEqual(0L, t1.GetUtcOffset (d3).Ticks, "D12");
		Assert.AreEqual(36000000000L, t1.GetUtcOffset (d4).Ticks, "D13");
		Assert.AreEqual(0L, t1.GetUtcOffset (d5).Ticks, "D14");
	}
开发者ID:mpareja,项目名称:mono,代码行数:28,代码来源:TimeZoneTest.cs

示例8: 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");
	}
开发者ID:mpareja,项目名称:mono,代码行数:16,代码来源:TimeZoneTest.cs

示例9: NZST

	private void NZST(TimeZone t1) {
		Assert.AreEqual("NZST", t1.StandardName, "E01");
		Assert.AreEqual("NZDT", t1.DaylightName, "E02");

		DaylightTime d1 = t1.GetDaylightChanges (2013);
		Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString ("G"), "E03");
		Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString ("G"), "E04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "E05");

		DaylightTime d2 = t1.GetDaylightChanges (2001);
		Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString ("G"), "E06");
		Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString ("G"), "E07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "E08");

		DateTime d3 = new DateTime(2013,02,15);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d3), "E09");
		DateTime d4 = new DateTime(2013,04,30);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d4), "E10");
		DateTime d5 = new DateTime(2013,11,03);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d5), "E11");

		Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d3).Ticks, "E12");
		Assert.AreEqual(36000000000L /*hour*/ * 12L, t1.GetUtcOffset (d4).Ticks, "E13");
		Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d5).Ticks, "E14");
	}
开发者ID:mpareja,项目名称:mono,代码行数:25,代码来源:TimeZoneTest.cs

示例10: OccursInMonth

		/// <summary>
		/// Returns true if the specified DayEntry is within the same month as <c>month</c>;
		/// </summary>
		/// <param name="dayEntry"></param>
		/// <param name="timeZone"></param>
		/// <param name="month"></param>
		/// <returns></returns>
		public static bool OccursInMonth(DayEntry dayEntry, TimeZone timeZone, 
			DateTime month)
		{
			DateTime startOfMonth = new DateTime(month.Year, month.Month, 1, 0, 0, 0);
			DateTime endOfMonth = new DateTime(month.Year, month.Month, 1, 0, 0, 0);
			endOfMonth = endOfMonth.AddMonths(1);
			endOfMonth = endOfMonth.AddSeconds(-1);
			
			TimeSpan offset = timeZone.GetUtcOffset(endOfMonth);
			endOfMonth = endOfMonth.AddHours(offset.Negate().Hours);
			return ( OccursBetween(dayEntry, timeZone, startOfMonth, endOfMonth) );
		}
开发者ID:plntxt,项目名称:dasblog,代码行数:19,代码来源:DayEntry.cs

示例11: ServerInfo

		public ServerInfo(string name, int fullPercent, TimeZone tz, IPEndPoint address)
		{
			Name = name;
			FullPercent = fullPercent;
			TimeZone = tz.GetUtcOffset(DateTime.Now).Hours;
			Address = address;
		}
开发者ID:Ravenwolfe,项目名称:ServUO,代码行数:7,代码来源:Packets.cs

示例12: NZST

	private void NZST(TimeZone t1) {
		Assert.AreEqual("NZST", t1.StandardName, "E01");
		Assert.AreEqual("NZDT", t1.DaylightName, "E02");

		DaylightTime d1 = t1.GetDaylightChanges (2013);
		Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "E03");
		Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "E04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "E05");

		DaylightTime d2 = t1.GetDaylightChanges (2001);
		Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "E06");
		Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "E07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "E08");

		DateTime d3 = new DateTime(2013,02,15);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d3), "E09");
		DateTime d4 = new DateTime(2013,04,30);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d4), "E10");
		DateTime d5 = new DateTime(2013,11,03);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d5), "E11");

		Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d3).Ticks, "E12");
		Assert.AreEqual(36000000000L /*hour*/ * 12L, t1.GetUtcOffset (d4).Ticks, "E13");
		Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d5).Ticks, "E14");

		// Test TimeZone methods with UTC DateTime in DST.
		DateTime d6 = d5.ToUniversalTime ();
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "E15");
		Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "E16");
	}
开发者ID:caomw,项目名称:mono,代码行数:30,代码来源:TimeZoneTest.cs

示例13: TST

	private void TST (TimeZone t1) 
	{
		AssertEquals("C01", "Tokyo Standard Time", t1.StandardName);
		AssertEquals("C02", "Tokyo Standard Time", t1.DaylightName);

		DateTime d3 = new DateTime (2002,2,25);
		AssertEquals("C09", false, t1.IsDaylightSavingTime (d3));
		DateTime d4 = new DateTime (2002,4,8);
		AssertEquals("C10", false, t1.IsDaylightSavingTime (d4));
		DateTime d5 = new DateTime (2002,11,4);
		AssertEquals("C11", false, t1.IsDaylightSavingTime (d5));

		AssertEquals("C12", 324000000000L, t1.GetUtcOffset (d3).Ticks);
		AssertEquals("C13", 324000000000L, t1.GetUtcOffset (d4).Ticks);
		AssertEquals("C14", 324000000000L, t1.GetUtcOffset (d5).Ticks);
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:16,代码来源:TimeZoneTest.cs


注:本文中的System.TimeZone.GetUtcOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。