99 lines
2.8 KiB
C#
99 lines
2.8 KiB
C#
/*********************************************************************************************
|
|
* Copyright 2004 - Volian Enterprises, Inc. All rights reserved.
|
|
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
|
* ------------------------------------------------------------------------------
|
|
* $Workfile: VEdt.cs $ $Revision: 1 $
|
|
* $Author: Kathy $ $Date: 7/27/04 8:35a $
|
|
*
|
|
* $History: VEdt.cs $
|
|
*
|
|
* ***************** Version 1 *****************
|
|
* User: Kathy Date: 7/27/04 Time: 8:35a
|
|
* Created in $/LibSource/Utils
|
|
*********************************************************************************************/
|
|
|
|
using System;
|
|
|
|
namespace Utils
|
|
{
|
|
/// <summary>
|
|
/// Summary description for VEdt.
|
|
/// </summary>
|
|
public class VEDateTime
|
|
{
|
|
public DateTime dt;
|
|
public string dtstr;
|
|
|
|
public VEDateTime(long tm)
|
|
{
|
|
System.Globalization.CultureInfo info =
|
|
new System.Globalization.CultureInfo("en-US", false);
|
|
|
|
System.Globalization.Calendar calendar = info.Calendar;
|
|
|
|
|
|
// do some conversion so that proms will be able to use this
|
|
// date/time. Proms had it in seconds since 00:00:00 1/1/1970.
|
|
// .NET has it in ticks since 00:00:00 1/1/1
|
|
DateTime promsdt = new DateTime(1970,1,1,0,0,0,0); // Jan 1, 1970
|
|
|
|
//
|
|
// Get the offset time between this time zone and UTC (GMT) time.
|
|
// Convert the offset to seconds.
|
|
// Subtract the offset from the UTC time gotten for Jan 1, 1970
|
|
ThisTimeZone TZ = new ThisTimeZone();
|
|
TimeSpan TimeZoneSpan = TZ.GetUtcOffset(promsdt); // Time Zone offset from UTC
|
|
long TimeZoneAdj = Math.Abs(TimeZoneSpan.Ticks / 10000000); // convert to seconds
|
|
DateTime cnv = promsdt.AddSeconds(tm-TimeZoneAdj);
|
|
dtstr = cnv.ToLongDateString() + " " + cnv.ToLongTimeString();
|
|
}
|
|
}
|
|
/*
|
|
* TimeZone is an Abstract Class. You need to inherit the TimeZone Class
|
|
* and overload a couple of it's functions in order to use it.
|
|
* - called in CalculatePromsDate() above.
|
|
*/
|
|
public class ThisTimeZone : TimeZone
|
|
{
|
|
private TimeZone curTZ;
|
|
public TimeSpan SpanTZ;
|
|
|
|
public ThisTimeZone()
|
|
{
|
|
curTZ = CurrentTimeZone; // local timezone
|
|
}
|
|
|
|
// get the UTC (GMT) value for the given date/time
|
|
public override TimeSpan GetUtcOffset(DateTime ForThisDate)
|
|
{
|
|
SpanTZ = curTZ.GetUtcOffset(ForThisDate);
|
|
return SpanTZ;
|
|
}
|
|
|
|
// Name of the local Daylight savings time zone
|
|
public override string DaylightName
|
|
{
|
|
get
|
|
{
|
|
return curTZ.DaylightName;
|
|
}
|
|
}
|
|
|
|
// Name of the local standard time zone
|
|
public override string StandardName
|
|
{
|
|
get
|
|
{
|
|
return curTZ.StandardName;
|
|
}
|
|
}
|
|
|
|
// Get the start and end dates for daylight savings
|
|
public override System.Globalization.DaylightTime GetDaylightChanges(int year)
|
|
{
|
|
return curTZ.GetDaylightChanges(year);
|
|
}
|
|
}
|
|
}
|
|
|