Click here to Skip to main content
15,896,912 members
Articles / Programming Languages / C#

A TimeZone Aware DateTime Implementation

Rate me:
Please Sign up or sign in to vote.
3.56/5 (10 votes)
24 Feb 2010CPOL6 min read 70.4K   466   37  
An implementation that wraps DateTime to allow for keeping track of TimeZone state
using System.Collections.Generic;
using NUnit.Framework;
using DateTimeZone;
using VizTimeZone = DateTimeZone.TimeZone;

namespace TestDateTimeZone
{
	/// <summary>
	/// Class summary...
	/// </summary>
	[TestFixture]
	public class TimeZonesTest
	{

		/// <summary>
		/// A test sample method.
		/// </summary>
		[Test]
		public void TestTimeZones()
		{
			IDictionary<string, VizTimeZone> timeZones = TimeZoneUtil.GetTimeZones(12, 45);
			Assert.IsTrue(timeZones.Count > 0);
		}

		[Test]
		public void TestMapAllTimeZones()
		{
			TimeZoneUtil.GetAllTimeZones();
			VizTimeZone timeZone = TimeZoneUtil.GetAllTimeZones()["HST"];
			Assert.AreSame(timeZone.CanonicalID, "HST");
		}
		
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Norway Norway
http://www.linkedin.com/in/steinardragsnes

Comments and Discussions