A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Updated Unix Timestamp Converter (#509)
Sou Niyariad1a27830e61
diff --git a/src/dev/impl/DevToys/DevToys.csproj b/src/dev/impl/DevToys/DevToys.csprojindex 7bb7d87c8..ad1a8c0b4 100644--- a/src/dev/impl/DevToys/DevToys.csproj+++ b/src/dev/impl/DevToys/DevToys.csproj@@ -36,6 +36,7 @@<Compile Include="Helpers\HashingHelper.cs" /><Compile Include="Helpers\NumberBaseHelper.cs" /><Compile Include="Helpers\StringManipulationHelper.cs" />+ <Compile Include="Helpers\TimestampToolHelper.cs" /><Compile Include="Helpers\XmlHelper.cs" /><Compile Include="Helpers\SqlFormatter\Core\Formatter.cs" /><Compile Include="Helpers\SqlFormatter\Core\Indentation.cs" />diff --git a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.csnew file mode 100644index 000000000..ceaff138d--- /dev/null+++ b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs@@ -0,0 +1,106 @@+#nullable enable++using System;+using System.Collections.Generic;+using System.Collections.ObjectModel;+using System.Linq;+using System.Text.RegularExpressions;++namespace DevToys.Helpers+{+ internal static class TimestampToolHelper+ {+ internal static class ZoneInfo+ {+ private static string _utcDisplayName = "";+ private static string _localDisplayName = "";+ private static readonly IReadOnlyCollection<TimeZoneInfo> _systemTimeZone = TimeZoneInfo.GetSystemTimeZones();+ private static readonly IReadOnlyDictionary<string, string> _timeZoneCollection = InitTimeZoneCollection();++ internal static string UtcDisplayName => _utcDisplayName;++ internal static string LocalDisplayName => _localDisplayName;++ internal static IReadOnlyList<string> DisplayNames => _timeZoneCollection.Keys.ToList();++ internal static IReadOnlyDictionary<string, string> TimeZones => _timeZoneCollection;++ private static IReadOnlyDictionary<string, string> InitTimeZoneCollection()+ {+ Dictionary<string, string> timeZoneCollection = new();+ if (!Regex.IsMatch(_systemTimeZone.ElementAt(0).DisplayName, @"^\(UTC.*\).+$"))+ {+ // version < .Net6+ // This implementation mitigates the changes in the strings+ // that are obtained when optimized in release builds,+ // as the target of external tools is .net6 or earlier.+ // zone.DisplayName : "(UTC+09:00) 大阪、札幌、東京"( >= .net6) or "東京 (標準時)"( < .net6)+ foreach (TimeZoneInfo zone in _systemTimeZone)+ {+ string displayName = $"(UTC{zone.BaseUtcOffset.Hours:+00;-00;}:{zone.BaseUtcOffset.Minutes:00;00;}) " + zone.DisplayName;+ if (zone.Id == TimeZoneInfo.Utc.Id)+ {+ displayName = "(UTC) " + zone.DisplayName;+ _utcDisplayName = "(UTC) " + zone.DisplayName;+ }+ if (zone.Id == TimeZoneInfo.Local.Id)+ {+ _localDisplayName = displayName;+ }+ timeZoneCollection.Add(displayName, zone.Id);+ }+ }+ else+ {+ // version >= .Net6+ foreach (TimeZoneInfo zone in _systemTimeZone)+ {+ timeZoneCollection.Add(zone.DisplayName, zone.Id);+ }+ _utcDisplayName = TimeZoneInfo.Utc.DisplayName;+ _localDisplayName = TimeZoneInfo.Local.DisplayName;+ }+ return timeZoneCollection;+ }+ }++ internal static class TimeZone+ {+ internal static DateTimeOffset SafeMinValue(TimeZoneInfo timezone)+ {+ if (timezone is null)+ {+ timezone = TimeZoneInfo.Utc;+ }+ DateTimeOffset t1 = TimeZoneInfo.ConvertTime(+ new DateTimeOffset(10, 1, 1, 0, 0, 0, TimeZoneInfo.Utc.BaseUtcOffset),+ timezone);+ DateTimeOffset minValue = DateTimeOffset.MinValue;+ if (t1.Year < 10)+ {+ minValue = minValue.Subtract(t1.Offset);+ }+ return TimeZoneInfo.ConvertTime(minValue, timezone);+ }++ internal static DateTimeOffset SafeMaxValue(TimeZoneInfo timezone)+ {+ if (timezone is null)+ {+ timezone = TimeZoneInfo.Utc;+ }+ DateTimeOffset t1 = TimeZoneInfo.ConvertTime(+ new DateTimeOffset(9990, 12, 31, 23, 59, 59, TimeZoneInfo.Utc.BaseUtcOffset),+ timezone);+ DateTimeOffset maxValue = DateTimeOffset.MaxValue;+ if (t1.Year > 9990)+ {+ maxValue = maxValue.Subtract(t1.Offset);+ }+ return TimeZoneInfo.ConvertTime(maxValue, timezone);+ }++ }++ }+}diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.csindex 4c2586351..5ff95fa2e 100644--- a/src/dev/impl/DevToys/LanguageManager.cs+++ b/src/dev/impl/DevToys/LanguageManager.cs@@ -2731,6 +2731,16 @@ namespace DevToys/// </summary>public string AccessibleName => _resources.GetString("AccessibleName");+ /// <summary>+ /// Gets the resource TimeZoneTitle.+ /// </summary>+ public string TimeZoneTitle => _resources.GetString("TimeZoneTitle");++ /// <summary>+ /// Gets the resource DaylightSavingTime.+ /// </summary>+ public string DaylightSavingTime => _resources.GetString("DaylightSavingTime");+/// <summary>/// Gets the resource DayTitle./// </summary>@@ -2741,6 +2751,16 @@ namespace DevToys/// </summary>public string Description => _resources.GetString("Description");+ /// <summary>+ /// Gets the resource DisabledDaylightSavingTime.+ /// </summary>+ public string DisabledDaylightSavingTime => _resources.GetString("DisabledDaylightSavingTime");++ /// <summary>+ /// Gets the resource DSTAmbiguousTime.+ /// </summary>+ public string DSTAmbiguousTime => _resources.GetString("DSTAmbiguousTime");+/// <summary>/// Gets the resource HourTitle./// </summary>@@ -2771,6 +2791,11 @@ namespace DevToys/// </summary>public string MonthTitle => _resources.GetString("MonthTitle");+ /// <summary>+ /// Gets the resource OffsetTitle.+ /// </summary>+ public string OffsetTitle => _resources.GetString("OffsetTitle");+/// <summary>/// Gets the resource SearchDisplayName./// </summary>@@ -2786,6 +2811,11 @@ namespace DevToys/// </summary>public string SecondsTitle => _resources.GetString("SecondsTitle");+ /// <summary>+ /// Gets the resource SupportsDaylightSavingTime.+ /// </summary>+ public string SupportsDaylightSavingTime => _resources.GetString("SupportsDaylightSavingTime");+/// <summary>/// Gets the resource TimestampTitle./// </summary>@@ -2796,6 +2826,11 @@ namespace DevToys/// </summary>public string UTCDateTime => _resources.GetString("UTCDateTime");+ /// <summary>+ /// Gets the resource UtcTicksTitle.+ /// </summary>+ public string UtcTicksTitle => _resources.GetString("UtcTicksTitle");+/// <summary>/// Gets the resource YearTitle./// </summary>diff --git a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw b/src/dev/impl/DevToys/Strings/en-US/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.reswindex 604d29341..db2b94207 100644--- a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Convertitore Unix Timestamp</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Giorno</value></data><data name="Description" xml:space="preserve"><value>Converti date di tipo timestamp in date accessibili all'uomo e viceversa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Ora (24 ore)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Mese</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Convertitore Unix Timestap</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Secondi</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>Data e ora UTC</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Anno</value></data>diff --git a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.reswindex 93d8f1bea..1243f1132 100644--- a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw@@ -120,17 +120,29 @@<data name="AccessibleName" xml:space="preserve"><value>Unix タイムスタンプ変換ツール</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>タイムゾーン</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>夏時間 (サマータイム) 適用期間です</value>+ </data><data name="DayTitle" xml:space="preserve"><value>日</value></data><data name="Description" xml:space="preserve">- <value>Unix 時間やUTCなどの日時を変換</value>+ <value>Unix 時間や UTC などの日時を変換</value>+ </data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>夏時間 (サマータイム) 規則はありません</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>夏時間の切り替えによる重複が発生しています</value></data><data name="HourTitle" xml:space="preserve"><value>時 (24 時間)</value></data><data name="InvalidValue" xml:space="preserve">- <value>使用できない文字が含まれています</value>+ <value>変換できる範囲を超えています</value></data><data name="LocalDateTime" xml:space="preserve"><value>ローカル日時</value>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>月</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>オフセット</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix タイムスタンプ変換</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>秒</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>夏時間 (サマータイム) 規則があります</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>タイムスタンプ</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC (協定世界時)</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks 値</value>+ </data><data name="YearTitle" xml:space="preserve"><value>年</value></data>diff --git a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.reswindex c4edfd683..900451166 100644--- a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>타임스탬프 변환기</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>일</value></data><data name="Description" xml:space="preserve"><value>타임스탬프를 읽기 쉬운 날짜로 변환하거나 반대로 변환합니다.</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>시 (24 시간제)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>월</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix 타임스탬프 변환기</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>초</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>타임스탬프</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC 날짜 및 시간</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>년</value></data>diff --git a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.reswindex 404df2c79..74966d64e 100644--- a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Ferramenta de Conversão do Carimbo Temporal</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Dia</value></data><data name="Description" xml:space="preserve"><value>Converte o carimbo temporal em data legível pelo ser humano e vice-versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hora (24 horas)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Mês</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Conversor Carimbo Temporal Unix</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Segundos</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Carimbo Temporal</value></data><data name="UTCDateTime" xml:space="preserve"><value>Data e Hora UTC</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Ano</value></data>diff --git a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.reswindex 1df179042..ded72ad0b 100644--- a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>Timestamp converter tool</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>Day</value></data><data name="Description" xml:space="preserve"><value>Convert timestamp to human-readable date and vice versa</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>Hour (24 hour)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>Month</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix Timestamp Converter</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>Seconds</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>Timestamp</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC Date and Time</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>Year</value></data>diff --git a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.reswindex 0307fed2a..7e1221137 100644--- a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>时间戳转换工具</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>日</value></data><data name="Description" xml:space="preserve"><value>将时间戳转换为人类可读的日期,反之亦然</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>小时(24小时制)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>月</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix 时间戳转换工具</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>秒</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>时间戳</value></data><data name="UTCDateTime" xml:space="preserve"><value>世界标准时间(UTC)</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>年</value></data>diff --git a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.reswindex 1e0471bad..f81f2ef0e 100644--- a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw+++ b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw@@ -120,12 +120,24 @@<data name="AccessibleName" xml:space="preserve"><value>時間戳轉換工具</value></data>+ <data name="TimeZoneTitle" xml:space="preserve">+ <value>Time zone</value>+ </data>+ <data name="DaylightSavingTime" xml:space="preserve">+ <value>Daylight saving time.</value>+ </data><data name="DayTitle" xml:space="preserve"><value>日</value></data><data name="Description" xml:space="preserve"><value>在時間戳和易讀格式間轉換</value></data>+ <data name="DisabledDaylightSavingTime" xml:space="preserve">+ <value>There is no daylight saving time.</value>+ </data>+ <data name="DSTAmbiguousTime" xml:space="preserve">+ <value>DST Ambiguous time.</value>+ </data><data name="HourTitle" xml:space="preserve"><value>時 (24 小時制)</value></data>@@ -144,6 +156,9 @@<data name="MonthTitle" xml:space="preserve"><value>月</value></data>+ <data name="OffsetTitle" xml:space="preserve">+ <value>Offset</value>+ </data><data name="SearchDisplayName" xml:space="preserve"><value>Unix 時間戳轉換工具</value></data>@@ -154,12 +169,18 @@<data name="SecondsTitle" xml:space="preserve"><value>秒</value></data>+ <data name="SupportsDaylightSavingTime" xml:space="preserve">+ <value>There is daylight saving time.</value>+ </data><data name="TimestampTitle" xml:space="preserve"><value>時間戳</value></data><data name="UTCDateTime" xml:space="preserve"><value>UTC 日期及時間</value></data>+ <data name="UtcTicksTitle" xml:space="preserve">+ <value>UtcTicks</value>+ </data><data name="YearTitle" xml:space="preserve"><value>年</value></data>diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.csindex 69cc58dfb..2517b7736 100644--- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs+++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs@@ -1,8 +1,10 @@#nullable enableusing System;+using System.Collections.Generic;using System.Composition;using DevToys.Api.Tools;+using DevToys.Helpers;using DevToys.Views.Tools.Timestamp;using Microsoft.Toolkit.Mvvm.ComponentModel;using Microsoft.Toolkit.Mvvm.Input;@@ -14,289 +16,275 @@ namespace DevToys.ViewModels.Tools.Timestamppublic sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel{private bool _isInputInvalid;++ internal IReadOnlyList<string> TimeZoneDisplayNameCollection = TimestampToolHelper.ZoneInfo.DisplayNames;+ private readonly IReadOnlyDictionary<string, string> _timeZoneCollection = TimestampToolHelper.ZoneInfo.TimeZones;+ private TimeZoneInfo _currentTimeZone = TimeZoneInfo.Utc;+ private string _currentTimeZoneDisplayName = TimestampToolHelper.ZoneInfo.UtcDisplayName;private double _timestamp;- private DateTime _utcDateTime;- private Lazy<DateTime> _localDateTime = null!;+ private DateTimeOffset _utcDateTime;+ private DateTimeOffset _zoneOffsetDateTime;+ private long _minimumZoneOffsetTimestamp = -62135596800;+ private long _maximumZoneOffsetTimestamp = 253402300799;++ private string _dstInfoDSTMessage = "";+ private string _dstInfoOffset = "";+ private string _dstInfoLocalDateTime = "";+ private string _dstInfoUtcDateTime = "";+ private string _dstInfoUtcTicks = "";public Type View => typeof(TimestampToolPage);internal TimestampStrings Strings => LanguageManager.Instance.Timestamp;+ /// <summary>+ /// Gets or sets true if the DateTimeOffset structure may exceed the settable range.+ /// </summary>internal bool IsInputInvalid{get => _isInputInvalid;set => SetProperty(ref _isInputInvalid, value);}- internal double Timestamp+ /// <summary>+ /// Daylight saving time display in DSTInfo block.+ /// Gets or sets text that displays whether it is+ /// daylight saving time support, in daylight saving time, or ambiguous time+ /// for a given time zone.+ /// </summary>+ internal string DSTInfoMessage{- get => _timestamp;- set- {- if (double.IsNaN(value))- {- _timestamp = 0;- }- else- {- _timestamp = value;- }-- ResetUtcDateTime();- ResetLocalDateTime();- }+ get => _dstInfoDSTMessage;+ set => SetProperty(ref _dstInfoDSTMessage, value);}- internal int UtcYear+ /// <summary>+ /// Local date and time value in DSTInfo block.+ /// Get or set the date and time converted to the time zone on the PC.+ /// (e.g. "2026/05/13 09:12:34")+ /// </summary>+ internal string DSTInfoLocalDateTime{- get => _utcDateTime.Year;- set- {- if (value < 1) // empty = -2147483648- {- return;- }-- if (UtcDay > DateTime.DaysInMonth(value, UtcMonth))- {- return;- }- if (!UpdateUtcDateTime(value, UtcMonth, UtcDay, UtcHour, UtcMinute, UtcSecond))- {- return;- }- ResetLocalDateTime();- ResetTimestamp();- }+ get => _dstInfoLocalDateTime;+ set => SetProperty(ref _dstInfoLocalDateTime, value);}- internal int UtcMonth+ /// <summary>+ /// Time zone offset value for DSTInfo block.+ /// Gets or sets the offset value that changes with the date and time in the specified time zone.+ /// (e.g. "+09:00")+ /// </summary>+ internal string DSTInfoOffsetValue{- get => _utcDateTime.Month;- set- {- if (value < 1) // empty = -2147483648- {- return;- }-- if (UtcDay > DateTime.DaysInMonth(UtcYear, value))- {- return;- }-- if (!UpdateUtcDateTime(UtcYear, value, UtcDay, UtcHour, UtcMinute, UtcSecond))- {- return;- }- ResetLocalDateTime();- ResetTimestamp();- }+ get => _dstInfoOffset;+ set => SetProperty(ref _dstInfoOffset, value);}- internal int UtcDay+ /// <summary>+ /// UTC date and time value in DSTInfo block.+ /// Gets or sets the string of the specified date and time converted to UTC(+00:00).+ /// (e.g. "2026/05/13 01:23:45")+ /// </summary>+ internal string DSTInfoUtcDateTime{- get => _utcDateTime.Day;- set- {- if (value < 1) // empty = -2147483648- {- return;- }+ get => _dstInfoUtcDateTime;+ set => SetProperty(ref _dstInfoUtcDateTime, value);+ }- if (value > DateTime.DaysInMonth(UtcYear, UtcMonth))- {- return;- }- if (!UpdateUtcDateTime(UtcYear, UtcMonth, value, UtcHour, UtcMinute, UtcSecond))- {- return;- }- ResetLocalDateTime();- ResetTimestamp();- }+ /// <summary>+ /// UTCTicks value in DSTInfo block.+ /// Gets or sets the string of the specified date and time converted to UTCTicks.+ /// </summary>+ internal string DSTInfoUtcTicks+ {+ get => _dstInfoUtcTicks;+ set => SetProperty(ref _dstInfoUtcTicks, value);}- internal int UtcHour+ private void DSTInfo(){- get => _utcDateTime.Hour;- set+ if (_currentTimeZone.IsAmbiguousTime(_zoneOffsetDateTime)){- if (value < 0) // empty = -2147483648- {- return;- }- if(!UpdateUtcDateTime(UtcYear, UtcMonth, UtcDay, value, UtcMinute, UtcSecond))- {- return;- }- ResetLocalDateTime();- ResetTimestamp();+ DSTInfoMessage = Strings.DSTAmbiguousTime;+ }+ else if (_currentTimeZone.IsDaylightSavingTime(_zoneOffsetDateTime))+ {+ DSTInfoMessage = Strings.DaylightSavingTime;+ }+ else if (_currentTimeZone.SupportsDaylightSavingTime)+ {+ DSTInfoMessage = Strings.SupportsDaylightSavingTime;+ }+ else+ {+ DSTInfoMessage = Strings.DisabledDaylightSavingTime;}+ DSTInfoOffsetValue = _zoneOffsetDateTime.ToString("zzz");+ DSTInfoLocalDateTime = _zoneOffsetDateTime.LocalDateTime.ToString("yyyy/MM/dd HH:mm:ss");+ DSTInfoUtcDateTime = _zoneOffsetDateTime.UtcDateTime.ToString("yyyy/MM/dd HH:mm:ss");+ DSTInfoUtcTicks = _zoneOffsetDateTime.UtcTicks.ToString();}- internal int UtcMinute+ /// <summary>+ /// Gets or sets the time zone name.+ /// This value is essentially the value of TimeZoneInfo.(zone).DisplayName (e.g. "(UTC) Coordinated Universal Time"),+ /// which is used to reverse lookup the time zone ID supported by the OS(e.g. TimeZoneInfo.Utc.Id -> "UTC").+ /// </summary>+ internal string CurrentTimeZoneDisplayName{- get => _utcDateTime.Minute;+ get => _currentTimeZoneDisplayName;set{- if (value < 0) // empty = -2147483648- {- return;- }- if (!UpdateUtcDateTime(UtcYear, UtcMonth, UtcDay, UtcHour, value, UtcSecond))+ if (_timeZoneCollection.TryGetValue(value, out string timeZoneID)){- return;+ _currentTimeZoneDisplayName = value;+ _currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneID);+ _minimumZoneOffsetTimestamp = TimestampToolHelper.TimeZone.SafeMinValue(_currentTimeZone)+ .ToUnixTimeSeconds();+ _maximumZoneOffsetTimestamp = TimestampToolHelper.TimeZone.SafeMaxValue(_currentTimeZone)+ .ToUnixTimeSeconds();+ UpdateZoneOffsetTimestamp(_timestamp);}- ResetLocalDateTime();- ResetTimestamp();}}- internal int UtcSecond+ /// <summary>+ /// Gets or sets the Unix time.+ /// -62135596800 (0001-01-01T00:00:00Z) to 253402300799 (9999-12-31T23:59:59Z) integer value.+ /// </summary>+ internal double Timestamp{- get => _utcDateTime.Second;+ get => _timestamp;set{- if (value < 0) // empty = -2147483648- {- return;- }- if (!UpdateUtcDateTime(UtcYear, UtcMonth, UtcDay, UtcHour, UtcMinute, value))- {- return;- }- ResetLocalDateTime();- ResetTimestamp();+ IsInputInvalid = false;+ UpdateZoneOffsetTimestamp(value);}}- internal int LocalYear+ /// <summary>+ /// Gets or sets the year value.+ /// </summary>+ internal int ZoneOffsetYear{- get => _localDateTime.Value.Year;+ get => _zoneOffsetDateTime.Year;set{if (value < 1) // empty = -2147483648{return;}-- if (LocalDay > DateTime.DaysInMonth(value, LocalMonth))- {- return;- }- if (!UpdateLocalDateTime(value, LocalMonth, LocalDay, LocalHour, LocalMinute, LocalSecond))+ if (!IsValidDateTime(value, ZoneOffsetMonth, ZoneOffsetDay, ZoneOffsetHour, ZoneOffsetMinute, ZoneOffsetSecond)){+ IsInputInvalid = true;return;}- ResetUtcDateTime();- ResetLocalDateTime();- ResetTimestamp();+ Timestamp = _utcDateTime.AddYears(value - _zoneOffsetDateTime.Year).ToUnixTimeSeconds();}}- internal int LocalMonth+ /// <summary>+ /// Gets or sets the month value.+ /// </summary>+ internal int ZoneOffsetMonth{- get => _localDateTime.Value.Month;+ get => _zoneOffsetDateTime.Month;set{- if (value < 1) // empty = -2147483648- {- return;- }-- if (LocalDay > DateTime.DaysInMonth(LocalYear, value))+ if (value < 0) // empty = -2147483648{return;}- if (!UpdateLocalDateTime(LocalYear, value, LocalDay, LocalHour, LocalMinute, LocalSecond))+ if (!IsValidDateTime(ZoneOffsetYear, value, ZoneOffsetDay, ZoneOffsetHour, ZoneOffsetMinute, ZoneOffsetSecond)){+ IsInputInvalid = true;return;}- ResetUtcDateTime();- ResetLocalDateTime();- ResetTimestamp();+ Timestamp = _utcDateTime.AddMonths(value - _zoneOffsetDateTime.Month).ToUnixTimeSeconds();}}- internal int LocalDay+ /// <summary>+ /// Gets or sets the day value.+ /// </summary>+ internal int ZoneOffsetDay{- get => _localDateTime.Value.Day;+ get => _zoneOffsetDateTime.Day;set{- if (value < 1) // empty = -2147483648- {- return;- }-- if (value > DateTime.DaysInMonth(LocalYear, LocalMonth))+ if (value < 0) // empty = -2147483648{return;}- if (!UpdateLocalDateTime(LocalYear, LocalMonth, value, LocalHour, LocalMinute, LocalSecond))+ if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, value, ZoneOffsetHour, ZoneOffsetMinute, ZoneOffsetSecond)){+ IsInputInvalid = true;return;}- ResetUtcDateTime();- ResetLocalDateTime();- ResetTimestamp();+ Timestamp = _utcDateTime.AddDays(value - _zoneOffsetDateTime.Day).ToUnixTimeSeconds();}}- internal int LocalHour+ /// <summary>+ /// Gets or sets the hour value.+ /// </summary>+ internal int ZoneOffsetHour{- get => _localDateTime.Value.Hour;+ get => _zoneOffsetDateTime.Hour;set{- if (value < 0) // empty = -2147483648+ if (value < -1) // empty = -2147483648{return;}- if (!UpdateLocalDateTime(LocalYear, LocalMonth, LocalDay, value, LocalMinute, LocalSecond))+ if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, ZoneOffsetDay, value, ZoneOffsetMinute, ZoneOffsetSecond)){+ IsInputInvalid = true;return;}- ResetUtcDateTime();- ResetLocalDateTime();- ResetTimestamp();+ Timestamp = _utcDateTime.AddHours(value - _zoneOffsetDateTime.Hour).ToUnixTimeSeconds();}}- internal int LocalMinute+ /// <summary>+ /// Gets or sets the minute value.+ /// </summary>+ internal int ZoneOffsetMinute{- get => _localDateTime.Value.Minute;+ get => _zoneOffsetDateTime.Minute;set{- if (value < 0) // empty = -2147483648+ if (value < -1) // empty = -2147483648{return;}- if (!UpdateLocalDateTime(LocalYear, LocalMonth, LocalDay, LocalHour, value, LocalSecond))+ if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, ZoneOffsetDay, ZoneOffsetHour, value, ZoneOffsetSecond)){+ IsInputInvalid = true;return;}- ResetUtcDateTime();- ResetLocalDateTime();- ResetTimestamp();+ Timestamp = _utcDateTime.AddMinutes(value - _zoneOffsetDateTime.Minute).ToUnixTimeSeconds();}}- internal int LocalSecond+ /// <summary>+ /// Gets or sets the second value.+ /// </summary>+ internal int ZoneOffsetSecond{- get => _localDateTime.Value.Second;+ get => _zoneOffsetDateTime.Second;set{- if (value < 0) // empty = -2147483648+ if (value < -1) // empty = -2147483648{return;}- if(!UpdateLocalDateTime(LocalYear, LocalMonth, LocalDay, LocalHour, LocalMinute, value))+ if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, ZoneOffsetDay, ZoneOffsetHour, ZoneOffsetMinute, value)){+ IsInputInvalid = true;return;}- ResetUtcDateTime();- ResetLocalDateTime();- ResetTimestamp();+ Timestamp = _utcDateTime.AddSeconds(value - _zoneOffsetDateTime.Second).ToUnixTimeSeconds();}}@@ -307,7 +295,8 @@ namespace DevToys.ViewModels.Tools.TimestampNowCommand = new RelayCommand(ExecuteNowCommand);// Set to the current epoch time.- Timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();+ Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();+ CurrentTimeZoneDisplayName = TimestampToolHelper.ZoneInfo.LocalDisplayName;}#region PasteCommand@@ -369,102 +358,137 @@ namespace DevToys.ViewModels.Tools.Timestampprivate void ExecuteNowCommand(){- Timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();- ResetUtcDateTime();- ResetLocalDateTime();+ Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();}#endregion- private void ResetUtcDateTime()+ private DateTimeOffset TimestampToUtcDateTime(double value){- try+ return DateTimeOffset.FromUnixTimeSeconds((long)value).UtcDateTime;+ }++ private void UpdateZoneOffsetTimestamp(double value)+ {+ if (double.IsNaN(value)){- _utcDateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds((long)Timestamp);- IsInputInvalid = false;+ value = 0;}- catch+ if (!IsValidTimestamp((long)value)){IsInputInvalid = true;- }+ if (value < 0)+ {+ value = _minimumZoneOffsetTimestamp;+ }+ else+ {+ value = _maximumZoneOffsetTimestamp;+ }- OnPropertyChanged(nameof(UtcYear));- OnPropertyChanged(nameof(UtcMonth));- OnPropertyChanged(nameof(UtcDay));- OnPropertyChanged(nameof(UtcHour));- OnPropertyChanged(nameof(UtcMinute));- OnPropertyChanged(nameof(UtcSecond));+ }+ _timestamp = value;+ _utcDateTime = TimestampToUtcDateTime(value);+ _zoneOffsetDateTime = TimeZoneInfo.ConvertTime(_utcDateTime, _currentTimeZone);+ DSTInfo();+ ResetZoneOffsetTimestamp();+ ResetZoneOffsetDateTime();}- private void ResetLocalDateTime()+ private bool IsValidTimestamp(long value){- _localDateTime = new Lazy<DateTime>(() => _utcDateTime.ToLocalTime());- OnPropertyChanged(nameof(LocalYear));- OnPropertyChanged(nameof(LocalMonth));- OnPropertyChanged(nameof(LocalDay));- OnPropertyChanged(nameof(LocalHour));- OnPropertyChanged(nameof(LocalMinute));- OnPropertyChanged(nameof(LocalSecond));+ if (value < _minimumZoneOffsetTimestamp || value > _maximumZoneOffsetTimestamp)+ {+ return false;+ }+ return true;}- private void ResetTimestamp()+ private bool IsValidDateTime(int Year, int Month, int Day, int Hour, int Minute, int Second){- _timestamp = new DateTimeOffset(_utcDateTime).ToUnixTimeSeconds();- OnPropertyChanged(nameof(Timestamp));- }+ if (Year is < 1 or > 9999)+ {+ return false;+ }- private bool UpdateUtcDateTime(int UtcYear, int UtcMonth, int UtcDay, int UtcHour, int UtcMinute, int UtcSecond)- {+ DateTimeOffset calcDateTime = TimeZoneInfo.ConvertTime(_zoneOffsetDateTime, TimeZoneInfo.Utc);+ calcDateTime = calcDateTime.AddYears(1970 - calcDateTime.Year);try{- var utcDateTime = new DateTime(UtcYear, UtcMonth, UtcDay, UtcHour, UtcMinute, UtcSecond, DateTimeKind.Utc);- long timestamp = new DateTimeOffset(utcDateTime).ToUnixTimeSeconds();- // TODO: UTC 9999/12/31 23:59:59 + LocalTime(+0030...) -> invalid LocalTime- // TODO: UTC 0001/01/01 00:00:00 + LocalTime(-0030...) -> invalid LocalTime- /*- if (timestamp is < (-62135596800) or > 253402300799)- {- IsInputInvalid = true;- return false;- }- */- DateTime localDateTime = utcDateTime.ToLocalTime();- _utcDateTime = utcDateTime;- IsInputInvalid = false;+ calcDateTime = calcDateTime.AddMonths(Month - _zoneOffsetDateTime.Month);+ calcDateTime = calcDateTime.AddDays(Day - _zoneOffsetDateTime.Day);+ calcDateTime = calcDateTime.AddHours(Hour - _zoneOffsetDateTime.Hour);+ calcDateTime = calcDateTime.AddMinutes(Minute - _zoneOffsetDateTime.Minute);+ calcDateTime = calcDateTime.AddSeconds(Second - _zoneOffsetDateTime.Second);}catch{- IsInputInvalid = true;return false;}- return true;- }-- private bool UpdateLocalDateTime(int LocalYear, int LocalMonth, int LocalDay, int LocalHour, int LocalMinute, int LocalSecond)- {- try+ calcDateTime = TimeZoneInfo.ConvertTime(calcDateTime, _currentTimeZone);+ TimeSpan offset = calcDateTime.Offset;++ if (Year + calcDateTime.Year - 1970 is > 1 and < 9999){- var localDateTime = new DateTime(LocalYear, LocalMonth, LocalDay, LocalHour, LocalMinute, LocalSecond, DateTimeKind.Local);- long timestamp = new DateTimeOffset(localDateTime.ToUniversalTime()).ToUnixTimeSeconds();- // TODO: UTC 9999/12/31 23:59:59 + LocalTime(+0030...) -> invalid LocalTime- // TODO: UTC 0001/01/01 00:00:00 + LocalTime(-0030...) -> invalid LocalTime- /*- if (timestamp is < (-62135596800) or > 253402300799)+ // 0002 ... 9998+ return true;+ }++ if (offset.TotalSeconds >= 0)+ {+ //UTC++ //example +01:00 Valid -> 0001/01/01 01:00:00 - 9999/12/31 23:59:59+ if (Year == 1){- IsInputInvalid = true;- return false;+ if (calcDateTime.UtcDateTime.Year < 1970)+ {+ return false;+ }+ }+ else //Year == 9999+ {+ if (calcDateTime.Year > 1970)+ {+ return false;+ }}- */- DateTime utcDateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(timestamp);- _timestamp = timestamp;- IsInputInvalid = false;}- catch+ else{- IsInputInvalid = true;- return false;+ //UTC-+ //example -01:00 Valid -> 0001/01/01 00:00:00 - 9999/12/31 22:59:59+ if (Year == 1)+ {+ if (calcDateTime.Year < 1970)+ {+ return false;+ }+ }+ else //Year == 9999+ {+ if (calcDateTime.UtcDateTime.Year > 1970)+ {+ return false;+ }+ }}return true;}++ private void ResetZoneOffsetDateTime()+ {+ OnPropertyChanged(nameof(ZoneOffsetYear));+ OnPropertyChanged(nameof(ZoneOffsetMonth));+ OnPropertyChanged(nameof(ZoneOffsetDay));+ OnPropertyChanged(nameof(ZoneOffsetHour));+ OnPropertyChanged(nameof(ZoneOffsetMinute));+ OnPropertyChanged(nameof(ZoneOffsetSecond));+ }++ private void ResetZoneOffsetTimestamp()+ {+ OnPropertyChanged(nameof(Timestamp));+ }+}}diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xamlindex d01aa51e2..545f62198 100644--- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml+++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml@@ -9,26 +9,183 @@mc:Ignorable="d"d:DesignHeight="400"d:DesignWidth="600">- <StackPanel Margin="0,0,0,16" Spacing="12">++ <Page.Resources>+ <Style+ x:Key="CardStyle"+ TargetType="Grid">+ <Setter+ Property="BorderBrush"+ Value="{ThemeResource ExpanderHeaderBorderBrush}" />+ <Setter+ Property="BorderThickness"+ Value="{ThemeResource ExpanderHeaderBorderThickness}" />+ <Setter+ Property="HorizontalAlignment"+ Value="Stretch" />+ <Setter+ Property="MinHeight"+ Value="{StaticResource ExpanderMinHeight}" />+ <Setter+ Property="Padding"+ Value="{StaticResource ExpanderContentPadding}" />+ <Setter+ Property="CornerRadius"+ Value="{ThemeResource ControlCornerRadius}" />+ <Setter+ Property="Background"+ Value="{ThemeResource ExpanderHeaderBackground}" />+ </Style>+ </Page.Resources>++ <StackPanel+ Margin="0,0,0,16"+ Spacing="12">++ <VisualStateManager.VisualStateGroups>+ <VisualStateGroup>+ <VisualState>+ <VisualState.StateTriggers>+ <AdaptiveTrigger+ MinWindowWidth="640" />+ </VisualState.StateTriggers>++ <VisualState.Setters>+ <Setter+ Target="ZoneOffsetDateGridBlock.Grid.ColumnSpan"+ Value="1" />++ <Setter+ Target="ZoneOffsetTimeGridBlock.Grid.Row"+ Value="0" />+ <Setter+ Target="ZoneOffsetTimeGridBlock.Grid.Column"+ Value="1" />+ <Setter+ Target="ZoneOffsetTimeGridBlock.Grid.ColumnSpan"+ Value="1" />+ </VisualState.Setters>+ </VisualState>+ </VisualStateGroup>+ </VisualStateManager.VisualStateGroups>++<StackPanel.ChildrenTransitions><TransitionCollection>- <EntranceThemeTransition IsStaggeringEnabled="True" FromVerticalOffset="50"/>+ <EntranceThemeTransition+ IsStaggeringEnabled="True"+ FromVerticalOffset="50" /></TransitionCollection></StackPanel.ChildrenTransitions>- <StackPanel Margin="0,12,0,0">-+ <StackPanel+ Margin="0,12,0,0"><muxc:InfoBarSeverity="Warning"Message="{x:Bind ViewModel.Strings.InvalidValue}"IsOpen="{x:Bind ViewModel.IsInputInvalid, Mode=OneWay}"- IsClosable="False"/>+ IsClosable="False" />+ </StackPanel>- <Grid>+ <!-- timezone -->+ <StackPanel>+ <TextBlock+ x:Name="CurrentTimeZonePickerHeaderTextBlock"+ Text="{x:Bind ViewModel.Strings.TimeZoneTitle}"+ Margin="{ThemeResource TextBoxTopHeaderMargin}"+ Style="{StaticResource SubTitleTextBlock}"+ TextWrapping="NoWrap"+ TextTrimming="CharacterEllipsis"+ VerticalAlignment="Bottom" />+ <ComboBox+ HorizontalAlignment="Stretch"+ AutomationProperties.LabeledBy="{Binding ElementName=CurrentTimeZonePickerHeaderTextBlock}"+ SelectedItem="{x:Bind ViewModel.CurrentTimeZoneDisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ ItemsSource="{x:Bind ViewModel.TimeZoneDisplayNameCollection}" />++ </StackPanel>+ <!-- timezone / -->++ <!-- Timezone info -->+ <StackPanel+ x:Name="Timezoneinfo">+ <Grid+ Style="{StaticResource CardStyle}"+ ColumnSpacing="12"+ RowSpacing="4"><Grid.ColumnDefinitions>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="Auto"/>+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="Auto" />+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="Auto" /></Grid.ColumnDefinitions>+ <Grid.RowDefinitions>+ <RowDefinition />+ <RowDefinition />+ <RowDefinition />+ <RowDefinition />+ </Grid.RowDefinitions>+ <TextBlock+ Grid.Row="0"+ Grid.Column="0"+ Grid.ColumnSpan="4"+ Text="{x:Bind ViewModel.DSTInfoMessage, Mode=OneWay}" />+ <TextBlock+ Grid.Row="1"+ Grid.Column="0"+ Text="{x:Bind ViewModel.Strings.OffsetTitle}" />+ <TextBlock+ Grid.Row="1"+ Grid.Column="1"+ Text="{x:Bind ViewModel.DSTInfoOffsetValue, Mode=OneWay}"+ IsTextSelectionEnabled="True" />+ <TextBlock+ Grid.Row="1"+ Grid.Column="2"+ Text="{x:Bind ViewModel.Strings.UtcTicksTitle}" />+ <TextBlock+ Grid.Row="1"+ Grid.Column="3"+ Text="{x:Bind ViewModel.DSTInfoUtcTicks, Mode=OneWay}"+ IsTextSelectionEnabled="True" />+ <TextBlock+ Grid.Row="2"+ Grid.Column="0"+ Text="{x:Bind ViewModel.Strings.LocalDateTime}" />+ <TextBlock+ Grid.Row="2"+ Grid.Column="1"+ Text="{x:Bind ViewModel.DSTInfoLocalDateTime, Mode=OneWay}"+ IsTextSelectionEnabled="True" />+ <TextBlock+ Grid.Row="2"+ Grid.Column="2"+ Text="{x:Bind ViewModel.Strings.UTCDateTime}" />+ <TextBlock+ Grid.Row="2"+ Grid.Column="3"+ Text="{x:Bind ViewModel.DSTInfoUtcDateTime, Mode=OneWay}"+ IsTextSelectionEnabled="True" />+ </Grid>+ </StackPanel>+ <!-- Timezone info / -->++ <!-- unixtime -->+ <StackPanel+ Visibility="Visible">+ <Grid+ Margin="0,0,0,0">+ <Grid.ColumnDefinitions>+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="Auto" />+ </Grid.ColumnDefinitions>+<TextBlockx:Name="TimestampHeaderTextBlock"Text="{x:Bind ViewModel.Strings.TimestampTitle}"@@ -36,7 +193,8 @@Style="{StaticResource SubTitleTextBlock}"TextWrapping="NoWrap"TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>+ VerticalAlignment="Bottom" />+ <!-- Button --><StackPanelGrid.Column="1"Orientation="Horizontal"@@ -48,281 +206,226 @@TabIndex="1"Command="{x:Bind ViewModel.NowCommand}"AutomationProperties.Name="{Binding Instance.Common.Now, Mode=OneTime, Source={StaticResource LanguageManager}}">- <StackPanel Orientation="Horizontal" Spacing="4" Height="21">- <TextBlock VerticalAlignment="Center" Text="{Binding Instance.Common.Now, Mode=OneTime, Source={StaticResource LanguageManager}}"/>+ <StackPanel+ Orientation="Horizontal"+ Spacing="4"+ Height="21">+ <TextBlock+ VerticalAlignment="Center"+ Text="{Binding Instance.Common.Now, Mode=OneTime, Source={StaticResource LanguageManager}}" /></StackPanel></Button><ButtonTabIndex="2"Command="{x:Bind ViewModel.PasteCommand}"AutomationProperties.Name="{Binding Instance.Common.Paste, Mode=OneTime, Source={StaticResource LanguageManager}}">- <StackPanel Orientation="Horizontal" Spacing="4">- <FontIcon Glyph=""/>- <TextBlock VerticalAlignment="Center" Text="{Binding Instance.Common.Paste, Mode=OneTime, Source={StaticResource LanguageManager}}"/>+ <StackPanel+ Orientation="Horizontal"+ Spacing="4">+ <FontIcon+ Glyph="" />+ <TextBlock+ VerticalAlignment="Center"+ Text="{Binding Instance.Common.Paste, Mode=OneTime, Source={StaticResource LanguageManager}}" /></StackPanel></Button><ButtonTabIndex="3"Command="{x:Bind ViewModel.CopyCommand}"AutomationProperties.Name="{Binding Instance.Common.Copy, Mode=OneTime, Source={StaticResource LanguageManager}}">- <StackPanel Orientation="Horizontal" Spacing="4">- <FontIcon Glyph=""/>- <TextBlock VerticalAlignment="Center" Text="{Binding Instance.Common.Copy, Mode=OneTime, Source={StaticResource LanguageManager}}"/>+ <StackPanel+ Orientation="Horizontal"+ Spacing="4">+ <FontIcon+ Glyph="" />+ <TextBlock+ VerticalAlignment="Center"+ Text="{Binding Instance.Common.Copy, Mode=OneTime, Source={StaticResource LanguageManager}}" /></StackPanel></Button></StackPanel>+ <!-- Button / --></Grid>- <muxc:NumberBox- Value="{x:Bind ViewModel.Timestamp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- LargeChange="10"- Minimum="{x:Bind local:TimestampToolPage.MinimumTimestamp}"- Maximum="{x:Bind local:TimestampToolPage.MaximumTimestamp}"- TabIndex="0"- AutomationProperties.LabeledBy="{Binding ElementName=TimestampHeaderTextBlock}"/>- </StackPanel>-- <TextBlock x:Name="UtcDateTime" Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.UTCDateTime}" />- <Grid ColumnSpacing="8" AutomationProperties.LabeledBy="{Binding ElementName=UtcDateTime}">- <Grid.ColumnDefinitions>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- </Grid.ColumnDefinitions>-- <StackPanel Grid.Column="0">- <TextBlock- x:Name="UtcYearHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.YearTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>+ <StackPanel><muxc:NumberBox- Value="{x:Bind ViewModel.UtcYear, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ Value="{x:Bind ViewModel.Timestamp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"SpinButtonPlacementMode="Compact"SmallChange="1"LargeChange="10"- Minimum="1"- Maximum="9999"- AutomationProperties.LabeledBy="{Binding ElementName=UtcYearHeaderTextBlock}"/>+ Minimum="{x:Bind local:TimestampToolPage.MinimumTimestamp}"+ Maximum="{x:Bind local:TimestampToolPage.MaximumTimestamp}"+ AutomationProperties.LabeledBy="{Binding ElementName=TimestampHeaderTextBlock}" /></StackPanel>- <StackPanel Grid.Column="1">- <TextBlock- x:Name="UtcMonthHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.MonthTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.UtcMonth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="1"- Maximum="12"- AutomationProperties.LabeledBy="{Binding ElementName=UtcMonthHeaderTextBlock}"/>- </StackPanel>+ </StackPanel>+ <!-- unixtime / -->- <StackPanel Grid.Column="2">- <TextBlock- x:Name="UtcDayHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.DayTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.UtcDay, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="1"- Maximum="31"- AutomationProperties.LabeledBy="{Binding ElementName=UtcDayHeaderTextBlock}"/>- </StackPanel>+ <Grid+ ColumnSpacing="8">+ <Grid.ColumnDefinitions>+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="*" />+ </Grid.ColumnDefinitions>+ <Grid.RowDefinitions>+ <RowDefinition />+ <RowDefinition />+ </Grid.RowDefinitions>- <StackPanel Grid.Column="3">- <TextBlock- x:Name="UtcHourHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.HourTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.UtcHour, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="0"- Maximum="23"- AutomationProperties.LabeledBy="{Binding ElementName=UtcHourHeaderTextBlock}"/>- </StackPanel>+ <!-- date -->+ <Grid+ x:Name="ZoneOffsetDateGridBlock"+ Grid.Row="0"+ Grid.Column="0"+ Grid.ColumnSpan="2"+ ColumnSpacing="8"+ Margin="0,12,0,0">+ <Grid.ColumnDefinitions>+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="*" />+ </Grid.ColumnDefinitions>- <StackPanel Grid.Column="4">- <TextBlock- x:Name="UtcMinuteHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.MinutesTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.UtcMinute, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="0"- Maximum="59"- AutomationProperties.LabeledBy="{Binding ElementName=UtcMinuteHeaderTextBlock}"/>- </StackPanel>+ <StackPanel+ Grid.Column="0">+ <TextBlock+ x:Name="ZoneOffsetYearHeaderTextBlock"+ Text="{x:Bind ViewModel.Strings.YearTitle}"+ Margin="{ThemeResource TextBoxTopHeaderMargin}"+ Style="{StaticResource SubTitleTextBlock}"+ TextWrapping="NoWrap"+ TextTrimming="CharacterEllipsis"+ VerticalAlignment="Bottom" />+ <muxc:NumberBox+ Value="{x:Bind ViewModel.ZoneOffsetYear, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ SpinButtonPlacementMode="Compact"+ SmallChange="1"+ LargeChange="10"+ Minimum="1"+ Maximum="9999"+ AutomationProperties.LabeledBy="{Binding ElementName=ZoneOffsetYearHeaderTextBlock}" />+ </StackPanel>- <StackPanel Grid.Column="5">- <TextBlock- x:Name="UtcSecondHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.SecondsTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.UtcSecond, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="0"- Maximum="59"- AutomationProperties.LabeledBy="{Binding ElementName=UtcSecondHeaderTextBlock}"/>- </StackPanel>- </Grid>+ <StackPanel+ Grid.Column="1">+ <TextBlock+ x:Name="ZoneOffsetMonthHeaderTextBlock"+ Text="{x:Bind ViewModel.Strings.MonthTitle}"+ Margin="{ThemeResource TextBoxTopHeaderMargin}"+ Style="{StaticResource SubTitleTextBlock}"+ TextWrapping="NoWrap"+ TextTrimming="CharacterEllipsis"+ VerticalAlignment="Bottom" />+ <muxc:NumberBox+ Value="{x:Bind ViewModel.ZoneOffsetMonth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ SpinButtonPlacementMode="Compact"+ SmallChange="1"+ Minimum="0"+ Maximum="13"+ AutomationProperties.LabeledBy="{Binding ElementName=ZoneOffsetMonthHeaderTextBlock}" />+ </StackPanel>- <TextBlock x:Name="LocalDateTime" Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.LocalDateTime}" />- <Grid ColumnSpacing="8" AutomationProperties.LabeledBy="{Binding ElementName=LocalDateTime}">- <Grid.ColumnDefinitions>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- <ColumnDefinition Width="*"/>- </Grid.ColumnDefinitions>+ <StackPanel+ Grid.Column="2">+ <TextBlock+ x:Name="ZoneOffsetDayHeaderTextBlock"+ Text="{x:Bind ViewModel.Strings.DayTitle}"+ Margin="{ThemeResource TextBoxTopHeaderMargin}"+ Style="{StaticResource SubTitleTextBlock}"+ TextWrapping="NoWrap"+ TextTrimming="CharacterEllipsis"+ VerticalAlignment="Bottom" />+ <muxc:NumberBox+ Value="{x:Bind ViewModel.ZoneOffsetDay, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ SpinButtonPlacementMode="Compact"+ SmallChange="1"+ Minimum="0"+ Maximum="32"+ AutomationProperties.LabeledBy="{Binding ElementName=ZoneOffsetDayHeaderTextBlock}" />+ </StackPanel>- <StackPanel Grid.Column="0">- <TextBlock- x:Name="YearHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.YearTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.LocalYear, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- LargeChange="10"- Minimum="1"- Maximum="9999"- AutomationProperties.LabeledBy="{Binding ElementName=YearHeaderTextBlock}"/>- </StackPanel>+ </Grid>+ <!-- time -->+ <Grid+ x:Name="ZoneOffsetTimeGridBlock"+ Grid.Row="1"+ Grid.Column="0"+ Grid.ColumnSpan="2"+ ColumnSpacing="8"+ Margin="0,12,0,0">+ <Grid.ColumnDefinitions>+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="*" />+ <ColumnDefinition+ Width="*" />+ </Grid.ColumnDefinitions>- <StackPanel Grid.Column="1">- <TextBlock- x:Name="MonthHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.MonthTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.LocalMonth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="1"- Maximum="12"- AutomationProperties.LabeledBy="{Binding ElementName=MonthHeaderTextBlock}"/>- </StackPanel>+ <StackPanel+ Grid.Column="0">+ <TextBlock+ x:Name="ZoneOffsetHourHeaderTextBlock"+ Text="{x:Bind ViewModel.Strings.HourTitle}"+ Margin="{ThemeResource TextBoxTopHeaderMargin}"+ Style="{StaticResource SubTitleTextBlock}"+ TextWrapping="NoWrap"+ TextTrimming="CharacterEllipsis"+ VerticalAlignment="Bottom" />+ <muxc:NumberBox+ Value="{x:Bind ViewModel.ZoneOffsetHour, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ SpinButtonPlacementMode="Compact"+ SmallChange="1"+ Minimum="-1"+ Maximum="24"+ AutomationProperties.LabeledBy="{Binding ElementName=ZoneOffsetHourHeaderTextBlock}" />+ </StackPanel>- <StackPanel Grid.Column="2">- <TextBlock- x:Name="DayHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.DayTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.LocalDay, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="1"- Maximum="31"- AutomationProperties.LabeledBy="{Binding ElementName=DayHeaderTextBlock}"/>- </StackPanel>+ <StackPanel+ Grid.Column="1">+ <TextBlock+ x:Name="ZoneOffsetMinuteHeaderTextBlock"+ Text="{x:Bind ViewModel.Strings.MinutesTitle}"+ Margin="{ThemeResource TextBoxTopHeaderMargin}"+ Style="{StaticResource SubTitleTextBlock}"+ TextWrapping="NoWrap"+ TextTrimming="CharacterEllipsis"+ VerticalAlignment="Bottom" />+ <muxc:NumberBox+ Value="{x:Bind ViewModel.ZoneOffsetMinute, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ SpinButtonPlacementMode="Compact"+ SmallChange="1"+ Minimum="-1"+ Maximum="60"+ AutomationProperties.LabeledBy="{Binding ElementName=ZoneOffsetMinuteHeaderTextBlock}" />+ </StackPanel>- <StackPanel Grid.Column="3">- <TextBlock- x:Name="HourHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.HourTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.LocalHour, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="0"- Maximum="23"- AutomationProperties.LabeledBy="{Binding ElementName=HourHeaderTextBlock}"/>- </StackPanel>+ <StackPanel+ Grid.Column="2">+ <TextBlock+ x:Name="ZoneOffsetSecondHeaderTextBlock"+ Text="{x:Bind ViewModel.Strings.SecondsTitle}"+ Margin="{ThemeResource TextBoxTopHeaderMargin}"+ Style="{StaticResource SubTitleTextBlock}"+ TextWrapping="NoWrap"+ TextTrimming="CharacterEllipsis"+ VerticalAlignment="Bottom" />+ <muxc:NumberBox+ Value="{x:Bind ViewModel.ZoneOffsetSecond, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ SpinButtonPlacementMode="Compact"+ SmallChange="1"+ Minimum="-1"+ Maximum="60"+ AutomationProperties.LabeledBy="{Binding ElementName=ZoneOffsetSecondHeaderTextBlock}" />+ </StackPanel>- <StackPanel Grid.Column="4">- <TextBlock- x:Name="MinuteHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.MinutesTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.LocalMinute, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="0"- Maximum="59"- AutomationProperties.LabeledBy="{Binding ElementName=MinuteHeaderTextBlock}"/>- </StackPanel>+ </Grid>- <StackPanel Grid.Column="5">- <TextBlock- x:Name="SecondHeaderTextBlock"- Text="{x:Bind ViewModel.Strings.SecondsTitle}"- Margin="{ThemeResource TextBoxTopHeaderMargin}"- Style="{StaticResource SubTitleTextBlock}"- TextWrapping="NoWrap"- TextTrimming="CharacterEllipsis"- VerticalAlignment="Bottom"/>- <muxc:NumberBox- Value="{x:Bind ViewModel.LocalSecond, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"- SpinButtonPlacementMode="Compact"- SmallChange="1"- Minimum="0"- Maximum="59"- AutomationProperties.LabeledBy="{Binding ElementName=SecondHeaderTextBlock}"/>- </StackPanel></Grid>+</StackPanel></Page>diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml.cs b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml.csindex 065ff501a..b59db5a3c 100644--- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml.cs+++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml.cs@@ -12,8 +12,8 @@ namespace DevToys.Views.Tools.Timestamp{public sealed partial class TimestampToolPage : Page{- public readonly static double MinimumTimestamp = (double)long.MinValue;- public readonly static double MaximumTimestamp = (double)long.MaxValue;+ public static readonly double MinimumTimestamp = -62135596800;+ public static readonly double MaximumTimestamp = 253402300799;public static readonly DependencyProperty ViewModelProperty= DependencyProperty.Register(@@ -48,15 +48,16 @@ namespace DevToys.Views.Tools.TimestampDataContext = ViewModel;}+ // Smart detectionif (!string.IsNullOrWhiteSpace(parameters.ClipBoardContent)){if (long.TryParse(parameters.ClipBoardContent, out long timestamp)){ViewModel.Timestamp = timestamp;}- else if (DateTime.TryParse(parameters.ClipBoardContent, out DateTime localDateTime))+ else if (DateTimeOffset.TryParse(parameters.ClipBoardContent, out DateTimeOffset clipboardDateTime)){- ViewModel.Timestamp = new DateTimeOffset(localDateTime.ToUniversalTime()).ToUnixTimeSeconds();+ ViewModel.Timestamp = clipboardDateTime.ToUnixTimeSeconds();}}