- worldclocks_src.zip
- WorldClocks
- Components
- PresentationUtility
- Graphics
- TimeZones.psd
- WorldClocks.sln
- WorldClocks
- App.xaml
- App.xaml.cs
- Controls
- Data
- Properties
- Resources
- Icons
- WorldClocks.ico
- WorldClocksTray.ico
- Images
- L1.png
- L10.png
- L2.png
- L3.5.png
- L3.png
- L4.png
- L5.png
- L6.png
- L7.png
- L8.png
- L9.5.png
- L9.png
- R1.png
- R10.png
- R11.png
- R12.png
- R2.png
- R3.5.png
- R3.png
- R4.5.png
- R4.png
- R5.5.png
- R5.png
- R6.5.png
- R6.png
- R7.png
- R8.png
- R9.5.png
- R9.png
- World.png
- Z0.png
- Windows
- WorldClocks.csproj
|
/////////////////////////////////////////////////////////////////////////////
//
// (c) 2007 BinaryComponents Ltd. All Rights Reserved.
//
// http://www.binarycomponents.com/
//
/////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace BinaryComponents.WorldClocks.Data
{
public sealed class TimeInfo
{
public TimeInfo( TimeZoneInfo tz )
{
_timezone = tz;
}
public static string Write( TimeInfo ti )
{
XDocument xDoc = new XDocument(
new XElement( "TimeInfo",
new XAttribute( "TimeZoneInfo", ti._timezone.ToSerializedString() ),
new XAttribute( "DisplayName", ti._displayName ?? string.Empty ) ) );
return xDoc.ToString();
}
public static TimeInfo Read( string s )
{
try
{
XDocument xDoc = XDocument.Parse( s );
TimeZoneInfo tzi = TimeZoneInfo.FromSerializedString( xDoc.Element( "TimeInfo" ).Attribute( "TimeZoneInfo" ).Value );
TimeInfo ti = new TimeInfo( tzi );
string displayName = xDoc.Element( "TimeInfo" ).Attribute( "DisplayName" ).Value.Trim();
if( displayName != string.Empty )
{
ti.DisplayName = displayName;
}
return ti;
}
catch
{
return null;
}
}
public static TimeInfo Copy( TimeInfo ti )
{
TimeInfo copy = new TimeInfo( ti.TimeZoneInfo );
if( ti.IsDisplayNameOverridden )
{
copy.DisplayName = ti.DisplayName;
}
return copy;
}
public bool IsDisplayNameOverridden
{
get
{
return _displayName != null;
}
}
public string OffsetName
{
get
{
if( _timezone.BaseUtcOffset == TimeSpan.Zero )
{
return "GMT";
}
else if( _timezone.BaseUtcOffset.Hours < 0 )
{
return string.Format( "GMT-{0}:{1:00}", -_timezone.BaseUtcOffset.Hours, -_timezone.BaseUtcOffset.Minutes );
}
else
{
return string.Format( "GMT+{0}:{1:00}", _timezone.BaseUtcOffset.Hours, _timezone.BaseUtcOffset.Minutes );
}
}
}
public string DisplayName
{
get
{
return _displayName ?? _timezone.DisplayName;
}
set
{
if( value == _timezone.DisplayName )
{
_displayName = null;
}
else
{
_displayName = value;
}
}
}
public TimeZoneInfo TimeZoneInfo
{
get
{
return _timezone;
}
}
public DateTime GetAdjusted( DateTime start )
{
return start.Add( _timezone.GetUtcOffset( start ) );
}
private TimeZoneInfo _timezone;
private string _displayName;
}
}
|
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.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
I'm currently working for a small start-up company, BinaryComponents Ltd, producing the FeedGhost RSS reader.
FeedGhost RSS Reader:
http://www.feedghost.com
Bespoke Software Development
http://www.binarycomponents.com