mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
feat: Add daylight time row entries & a new display name column to TimeZones.sqlite - Adjusted IcdTimeZoneInfo accordingly
This commit is contained in:
@@ -32,7 +32,9 @@ namespace ICD.Common.Utils.TimeZoneInfo
|
|||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
public string StandardName { get; private set; }
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
public string DisplayName { get; private set; }
|
||||||
|
|
||||||
public TimeSpan BaseUtcOffset { get; private set; }
|
public TimeSpan BaseUtcOffset { get; private set; }
|
||||||
|
|
||||||
@@ -66,6 +68,11 @@ namespace ICD.Common.Utils.TimeZoneInfo
|
|||||||
return s_Cache[timeZoneId];
|
return s_Cache[timeZoneId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool TryFindSystemTimeZoneById(string timeZoneId, out IcdTimeZoneInfo output)
|
||||||
|
{
|
||||||
|
return s_Cache.TryGetValue(timeZoneId, out output);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Cache Building
|
#region Cache Building
|
||||||
@@ -83,13 +90,13 @@ namespace ICD.Common.Utils.TimeZoneInfo
|
|||||||
sQLiteConnection.Open();
|
sQLiteConnection.Open();
|
||||||
|
|
||||||
foreach (IcdTimeZoneInfo info in ReadTimeZoneInfos(sQLiteConnection))
|
foreach (IcdTimeZoneInfo info in ReadTimeZoneInfos(sQLiteConnection))
|
||||||
s_Cache.Add(info.StandardName, info);
|
s_Cache.Add(info.Name, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<IcdTimeZoneInfo> ReadTimeZoneInfos(IcdSqliteConnection sQLiteConnection)
|
private static IEnumerable<IcdTimeZoneInfo> ReadTimeZoneInfos(IcdSqliteConnection sQLiteConnection)
|
||||||
{
|
{
|
||||||
const string command = "select id, name, baseOffsetTicks, hasDstRule from timeZones";
|
const string command = "select id, name, displayName, baseOffsetTicks, hasDstRule from timeZones";
|
||||||
|
|
||||||
using (IcdSqliteCommand cmd = new IcdSqliteCommand(command, sQLiteConnection))
|
using (IcdSqliteCommand cmd = new IcdSqliteCommand(command, sQLiteConnection))
|
||||||
{
|
{
|
||||||
@@ -99,14 +106,16 @@ namespace ICD.Common.Utils.TimeZoneInfo
|
|||||||
{
|
{
|
||||||
int id = reader.GetInt32(0);
|
int id = reader.GetInt32(0);
|
||||||
string name = reader.GetString(1);
|
string name = reader.GetString(1);
|
||||||
long offset = reader.GetInt64(2);
|
string display = reader.GetString(2);
|
||||||
bool hasRule = reader.GetBoolean(3);
|
long offset = reader.GetInt64(3);
|
||||||
|
bool hasRule = reader.GetBoolean(4);
|
||||||
|
|
||||||
IcdTimeZoneInfoAdjustmentRule[] adjustmentRules = LoadAdjustmentRules(id, sQLiteConnection).ToArray();
|
IcdTimeZoneInfoAdjustmentRule[] adjustmentRules = LoadAdjustmentRules(id, sQLiteConnection).ToArray();
|
||||||
|
|
||||||
IcdTimeZoneInfo info = new IcdTimeZoneInfo
|
IcdTimeZoneInfo info = new IcdTimeZoneInfo
|
||||||
{
|
{
|
||||||
StandardName = name,
|
Name = name,
|
||||||
|
DisplayName = display,
|
||||||
BaseUtcOffset = TimeSpan.FromTicks(offset),
|
BaseUtcOffset = TimeSpan.FromTicks(offset),
|
||||||
SupportsDaylightSavingTime = hasRule,
|
SupportsDaylightSavingTime = hasRule,
|
||||||
m_AdjustmentRules = adjustmentRules
|
m_AdjustmentRules = adjustmentRules
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user