From d03900e0d146d70501eb4d6cdfdb88bab652d12c Mon Sep 17 00:00:00 2001 From: niyari Date: Sat, 30 Apr 2022 10:00:20 +0900 Subject: [PATCH 01/26] Add string keywords. --- src/dev/impl/DevToys/LanguageManager.cs | 30 +++++++++++++++++++ .../impl/DevToys/Strings/en-US/Timestamp.resw | 18 +++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.cs index 73b0d60d9f..eff476953e 100644 --- a/src/dev/impl/DevToys/LanguageManager.cs +++ b/src/dev/impl/DevToys/LanguageManager.cs @@ -2625,6 +2625,21 @@ public class TimestampStrings : ObservableObject /// public string AccessibleName => _resources.GetString("AccessibleName"); + /// + /// Gets the resource CurrentDateTimeTitle. + /// + public string CurrentDateTimeTitle => _resources.GetString("CurrentDateTimeTitle"); + + /// + /// Gets the resource CurrentTimeZone. + /// + public string CurrentTimeZone => _resources.GetString("CurrentTimeZone"); + + /// + /// Gets the resource DaylightSavingTime. + /// + public string DaylightSavingTime => _resources.GetString("DaylightSavingTime"); + /// /// Gets the resource DayTitle. /// @@ -2635,6 +2650,16 @@ public class TimestampStrings : ObservableObject /// public string Description => _resources.GetString("Description"); + /// + /// Gets the resource DisabledDaylightSavingTime. + /// + public string DisabledDaylightSavingTime => _resources.GetString("DisabledDaylightSavingTime"); + + /// + /// Gets the resource DSTAmbiguousTime. + /// + public string DSTAmbiguousTime => _resources.GetString("DSTAmbiguousTime"); + /// /// Gets the resource HourTitle. /// @@ -2680,6 +2705,11 @@ public class TimestampStrings : ObservableObject /// public string SecondsTitle => _resources.GetString("SecondsTitle"); + /// + /// Gets the resource SupportsDaylightSavingTime. + /// + public string SupportsDaylightSavingTime => _resources.GetString("SupportsDaylightSavingTime"); + /// /// Gets the resource TimestampTitle. /// diff --git a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp From 366cce8211967a2e9559c4cbf52a15d38f2a6211 Mon Sep 17 00:00:00 2001 From: niyari Date: Sat, 30 Apr 2022 10:14:56 +0900 Subject: [PATCH 02/26] Update TimestampTool --- .../Timestamp/TimestampToolViewModel.cs | 522 ++++++++++-------- .../Timestamp/TimestampToolPage.xaml | 405 +++++++------- .../Timestamp/TimestampToolPage.xaml.cs | 9 +- 3 files changed, 495 insertions(+), 441 deletions(-) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 59eb32f79e..3409dc80d3 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -1,6 +1,8 @@ #nullable enable using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Composition; using DevToys.Api.Tools; using DevToys.Views.Tools.Timestamp; @@ -14,9 +16,25 @@ namespace DevToys.ViewModels.Tools.Timestamp public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel { private bool _isInputInvalid; - private double _timestamp; - private DateTime _utcDateTime; - private Lazy _localDateTime = null!; + private readonly long _minimumUtcTimestamp = -62135596800; + private readonly long _maximumUtcTimestamp = 253402300799; + + internal List TimeZoneDisplayNameCollection = new(); + private readonly Dictionary _timeZoneCollection = new(); + private readonly ReadOnlyCollection _systemTimeZone = TimeZoneInfo.GetSystemTimeZones(); + private TimeZoneInfo _currentTimeZone = TimeZoneInfo.Utc; + private string _currentTimeZoneDisplayName = TimeZoneInfo.Utc.DisplayName; + private double _currentTimestamp; + private DateTimeOffset _currentUtcDateTime; + private DateTimeOffset _currentDateTime; + private long _minimumCurrentTimestamp = -62135596800; + private long _maximumCurrentTimestamp = 253402300799; + + private bool _isSupportsDST; + private bool _isDisabledDST; + private bool _isDaylightSavingTime; + private bool _isDSTAmbiguousTime; + public Type View => typeof(TimestampToolPage); @@ -28,275 +46,304 @@ internal bool IsInputInvalid set => SetProperty(ref _isInputInvalid, value); } - internal double Timestamp + internal bool IsSupportsDST { - get => _timestamp; - set - { - if (double.IsNaN(value)) - { - _timestamp = 0; - } - else - { - _timestamp = value; - } + get => _isSupportsDST; + set => SetProperty(ref _isSupportsDST, value); + } - ResetUtcDateTime(); - ResetLocalDateTime(); - } + internal bool IsDisabledDST + { + get => _isDisabledDST; + set => SetProperty(ref _isDisabledDST, value); } - internal int UtcYear + internal bool IsDaylightSavingTime { - get => _utcDateTime.Year; - set - { - if (value < 1) // empty = -2147483648 - { - return; - } + get => _isDaylightSavingTime; + set => SetProperty(ref _isDaylightSavingTime, value); + } - if (UtcDay > DateTime.DaysInMonth(value, UtcMonth)) - { - return; - } - if (!UpdateUtcDateTime(value, UtcMonth, UtcDay, UtcHour, UtcMinute, UtcSecond)) - { - return; - } - ResetLocalDateTime(); - ResetTimestamp(); - } + internal bool IsDSTAmbiguousTime + { + get => _isDSTAmbiguousTime; + set => SetProperty(ref _isDSTAmbiguousTime, value); } - internal int UtcMonth + private void DSTInfo() { - get => _utcDateTime.Month; - set + IsDSTAmbiguousTime = false; + IsDaylightSavingTime = false; + IsSupportsDST = false; + IsDisabledDST = false; + if (_currentTimeZone.IsAmbiguousTime(_currentDateTime)) { - if (value < 1) // empty = -2147483648 - { - return; - } + IsDSTAmbiguousTime = true; + } + else if (_currentTimeZone.IsDaylightSavingTime(_currentDateTime)) + { + IsDaylightSavingTime = true; + } + else if (_currentTimeZone.SupportsDaylightSavingTime) + { + IsSupportsDST = true; + } + else + { + IsDisabledDST = true; + } - if (UtcDay > DateTime.DaysInMonth(UtcYear, value)) - { - return; - } + } - if (!UpdateUtcDateTime(UtcYear, value, UtcDay, UtcHour, UtcMinute, UtcSecond)) - { - return; - } - ResetLocalDateTime(); - ResetTimestamp(); + private void SetTimeZoneList() + { + foreach (TimeZoneInfo zone in _systemTimeZone) + { + _timeZoneCollection.Add(zone.DisplayName, zone.Id); + TimeZoneDisplayNameCollection.Add(zone.DisplayName); } + //TimeZoneCollection.Reverse(); + } - internal int UtcDay + internal string CurrentTimeZoneDisplayName { - get => _utcDateTime.Day; + get => _currentTimeZoneDisplayName; set { - if (value < 1) // empty = -2147483648 - { - return; + if (_timeZoneCollection.ContainsKey(value)) + { + _currentTimeZoneDisplayName = value; + _currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById(_timeZoneCollection[value]); + if (_currentTimeZone.BaseUtcOffset.TotalSeconds > 0) + { + // UTC+ + _minimumCurrentTimestamp = _minimumUtcTimestamp; + _maximumCurrentTimestamp = _maximumUtcTimestamp - (long)_currentTimeZone.BaseUtcOffset.TotalSeconds; + } + else + { + // UTC- + _minimumCurrentTimestamp = _minimumUtcTimestamp - (long)_currentTimeZone.BaseUtcOffset.TotalSeconds; + _maximumCurrentTimestamp = _maximumUtcTimestamp; + } + UpdateCurrentTimestamp(_currentTimestamp); } - if (value > DateTime.DaysInMonth(UtcYear, UtcMonth)) - { - return; - } - if (!UpdateUtcDateTime(UtcYear, UtcMonth, value, UtcHour, UtcMinute, UtcSecond)) - { - return; - } - ResetLocalDateTime(); - ResetTimestamp(); } } - internal int UtcHour + internal double CurrentTimestamp { - get => _utcDateTime.Hour; + get => _currentTimestamp; set { - if (value < 0) // empty = -2147483648 - { - return; - } - if(!UpdateUtcDateTime(UtcYear, UtcMonth, UtcDay, value, UtcMinute, UtcSecond)) + IsInputInvalid = false; + if (_currentTimestamp == value) { return; } - ResetLocalDateTime(); - ResetTimestamp(); + UpdateCurrentTimestamp(value); } } - internal int UtcMinute + internal int CurrentYear { - get => _utcDateTime.Minute; + get => _currentDateTime.Year; set { - if (value < 0) // empty = -2147483648 + if (value < 1) // empty = -2147483648 { return; } - if (!UpdateUtcDateTime(UtcYear, UtcMonth, UtcDay, UtcHour, value, UtcSecond)) + /* + if (CurrentDay > DateTime.DaysInMonth(value, CurrentMonth)) { return; } - ResetLocalDateTime(); - ResetTimestamp(); - } - } - - internal int UtcSecond - { - get => _utcDateTime.Second; - set - { - if (value < 0) // empty = -2147483648 + */ + try { - return; + if (IsValidDateTime(value, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) + { + _currentUtcDateTime = _currentUtcDateTime.AddYears(value - _currentDateTime.Year); + } + else + { + IsInputInvalid = true; + return; + } } - if (!UpdateUtcDateTime(UtcYear, UtcMonth, UtcDay, UtcHour, UtcMinute, value)) + catch { + IsInputInvalid = true; return; } - ResetLocalDateTime(); - ResetTimestamp(); + CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); } } - internal int LocalYear + internal int CurrentMonth { - get => _localDateTime.Value.Year; + get => _currentDateTime.Month; set { - if (value < 1) // empty = -2147483648 + if (value < 0) // empty = -2147483648 { return; } - - if (LocalDay > DateTime.DaysInMonth(value, LocalMonth)) + /* + if (CurrentDay > DateTime.DaysInMonth(CurrentYear, value)) { return; } - if (!UpdateLocalDateTime(value, LocalMonth, LocalDay, LocalHour, LocalMinute, LocalSecond)) + */ + try + { + if (IsValidDateTime(CurrentYear, value, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) + { + _currentUtcDateTime = _currentUtcDateTime.AddMonths(value - _currentDateTime.Month); + } + else + { + IsInputInvalid = true; + return; + } + } + catch { + ResetCurrentDateTime(); + IsInputInvalid = true; return; + } - ResetUtcDateTime(); - ResetLocalDateTime(); - ResetTimestamp(); + CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); } } - internal int LocalMonth + internal int CurrentDay { - get => _localDateTime.Value.Month; + get => _currentDateTime.Day; set { - if (value < 1) // empty = -2147483648 + if (value < 0) // empty = -2147483648 { return; } - - if (LocalDay > DateTime.DaysInMonth(LocalYear, value)) + /* + if (value > DateTime.DaysInMonth(CurrentYear, CurrentMonth)) { return; } - if (!UpdateLocalDateTime(LocalYear, value, LocalDay, LocalHour, LocalMinute, LocalSecond)) + */ + try { + if (IsValidDateTime(CurrentYear, CurrentMonth, value, CurrentHour, CurrentMinute, CurrentSecond)) + { + _currentUtcDateTime = _currentUtcDateTime.AddDays(value - _currentDateTime.Day); + } + else + { + IsInputInvalid = true; + return; + } + } + catch + { + IsInputInvalid = true; return; } - ResetUtcDateTime(); - ResetLocalDateTime(); - ResetTimestamp(); + CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); } } - internal int LocalDay + internal int CurrentHour { - get => _localDateTime.Value.Day; + get => _currentDateTime.Hour; set { - if (value < 1) // empty = -2147483648 + if (value < -1) // empty = -2147483648 { return; } - - if (value > DateTime.DaysInMonth(LocalYear, LocalMonth)) + try { - return; + if (IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, value, CurrentMinute, CurrentSecond)) + { + _currentUtcDateTime = _currentUtcDateTime.AddHours(value - _currentDateTime.Hour); + } + else + { + IsInputInvalid = true; + return; + } } - if (!UpdateLocalDateTime(LocalYear, LocalMonth, value, LocalHour, LocalMinute, LocalSecond)) + catch { + IsInputInvalid = true; return; } - ResetUtcDateTime(); - ResetLocalDateTime(); - ResetTimestamp(); + CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); } } - internal int LocalHour + internal int CurrentMinute { - get => _localDateTime.Value.Hour; + get => _currentDateTime.Minute; set { - if (value < 0) // empty = -2147483648 - { - return; - } - if (!UpdateLocalDateTime(LocalYear, LocalMonth, LocalDay, value, LocalMinute, LocalSecond)) + if (value < -1) // empty = -2147483648 { return; } - ResetUtcDateTime(); - ResetLocalDateTime(); - ResetTimestamp(); - } - } - - internal int LocalMinute - { - get => _localDateTime.Value.Minute; - set - { - if (value < 0) // empty = -2147483648 + try { - return; + if (IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, value, CurrentSecond)) + { + _currentUtcDateTime = _currentUtcDateTime.AddMinutes(value - _currentDateTime.Minute); + } + else + { + IsInputInvalid = true; + return; + } } - if (!UpdateLocalDateTime(LocalYear, LocalMonth, LocalDay, LocalHour, value, LocalSecond)) + catch { + IsInputInvalid = true; return; } - ResetUtcDateTime(); - ResetLocalDateTime(); - ResetTimestamp(); + CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); } } - internal int LocalSecond + internal int CurrentSecond { - get => _localDateTime.Value.Second; + get => _currentDateTime.Second; set { - if (value < 0) // empty = -2147483648 + if (value < -1) // empty = -2147483648 { return; } - if(!UpdateLocalDateTime(LocalYear, LocalMonth, LocalDay, LocalHour, LocalMinute, value)) + try { + if (IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, value)) + { + _currentUtcDateTime = _currentUtcDateTime.AddSeconds(value - _currentDateTime.Second); + } + else + { + IsInputInvalid = true; + return; + } + } + catch + { + IsInputInvalid = true; return; } - ResetUtcDateTime(); - ResetLocalDateTime(); - ResetTimestamp(); + CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); } } @@ -304,9 +351,11 @@ public TimestampToolViewModel() { PasteCommand = new RelayCommand(ExecutePasteCommand); CopyCommand = new RelayCommand(ExecuteCopyCommand); + SetTimeZoneList(); // Set to the current epoch time. - Timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + CurrentTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); + CurrentTimeZoneDisplayName = TimeZoneInfo.Local.DisplayName; } #region PasteCommand @@ -327,7 +376,7 @@ private async void ExecutePasteCommand() if (long.TryParse(text, out long value)) { - Timestamp = value; + CurrentTimestamp = value; } } catch (Exception ex) @@ -350,7 +399,7 @@ private void ExecuteCopyCommand() { RequestedOperation = DataPackageOperation.Copy }; - data.SetText(Timestamp.ToString()); + data.SetText(CurrentTimestamp.ToString()); Clipboard.SetContentWithOptions(data, new ClipboardContentOptions() { IsAllowedInHistory = true, IsRoamable = true }); Clipboard.Flush(); // This method allows the content to remain available after the application shuts down. @@ -363,95 +412,124 @@ private void ExecuteCopyCommand() #endregion - private void ResetUtcDateTime() + private DateTimeOffset TimestampToUtcDateTime(double value) { - try + return DateTimeOffset.FromUnixTimeSeconds((long)value).UtcDateTime; + } + + private void UpdateCurrentTimestamp(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)) + { + _currentTimestamp = value; + _currentUtcDateTime = TimestampToUtcDateTime(value); + _currentDateTime = TimeZoneInfo.ConvertTime(TimestampToUtcDateTime(value), _currentTimeZone); + DSTInfo(); + ResetCurrentTimestamp(); + ResetCurrentDateTime(); + } + else { IsInputInvalid = true; } - - OnPropertyChanged(nameof(UtcYear)); - OnPropertyChanged(nameof(UtcMonth)); - OnPropertyChanged(nameof(UtcDay)); - OnPropertyChanged(nameof(UtcHour)); - OnPropertyChanged(nameof(UtcMinute)); - OnPropertyChanged(nameof(UtcSecond)); } - private void ResetLocalDateTime() + private bool IsValidTimestamp(long value) { - _localDateTime = new Lazy(() => _utcDateTime.ToLocalTime()); - OnPropertyChanged(nameof(LocalYear)); - OnPropertyChanged(nameof(LocalMonth)); - OnPropertyChanged(nameof(LocalDay)); - OnPropertyChanged(nameof(LocalHour)); - OnPropertyChanged(nameof(LocalMinute)); - OnPropertyChanged(nameof(LocalSecond)); - } - - private void ResetTimestamp() - { - _timestamp = new DateTimeOffset(_utcDateTime).ToUnixTimeSeconds(); - OnPropertyChanged(nameof(Timestamp)); + if (value < _minimumCurrentTimestamp || value > _maximumCurrentTimestamp) + { + return false; + } + // TODO: + //return TimeZoneInfo.ConvertTime(TimestampToUtcDateTime(value), _currentTimeZone).ToUnixTimeSeconds() == value; + return true; } - private bool UpdateUtcDateTime(int UtcYear, int UtcMonth, int UtcDay, int UtcHour, int UtcMinute, int UtcSecond) + private bool IsValidDateTime(int Year, int Month, int Day, int Hour, int Minute, int Second) { + if (Year is < 1 or > 9999) + { + return false; + } + TimeSpan offset = _currentTimeZone.BaseUtcOffset; + DateTimeOffset calcDateTime = new(1970, 1, 1, 0, 0, 0, offset); 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 - 1); + calcDateTime = calcDateTime.AddDays(Day - 1); + calcDateTime = calcDateTime.AddHours(Hour); + calcDateTime = calcDateTime.AddMinutes(Minute); + calcDateTime = calcDateTime.AddSeconds(Second); } catch { - IsInputInvalid = true; return false; } - return true; - } - - private bool UpdateLocalDateTime(int LocalYear, int LocalMonth, int LocalDay, int LocalHour, int LocalMinute, int LocalSecond) - { - try + + 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) + 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 ResetCurrentDateTime() + { + OnPropertyChanged(nameof(CurrentYear)); + OnPropertyChanged(nameof(CurrentMonth)); + OnPropertyChanged(nameof(CurrentDay)); + OnPropertyChanged(nameof(CurrentHour)); + OnPropertyChanged(nameof(CurrentMinute)); + OnPropertyChanged(nameof(CurrentSecond)); + } + + private void ResetCurrentTimestamp() + { + OnPropertyChanged(nameof(CurrentTimestamp)); + } + } } diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 3eed8a1577..064f6a14bc 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -9,312 +9,287 @@ mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="600"> - + + - + - - + + IsClosable="False" /> + + + + + + + - + - - + + - + - - + - + + + + + + - - - + - - - - - - + + + + + + - + + VerticalAlignment="Bottom" /> + AutomationProperties.LabeledBy="{Binding ElementName=CurrentYearHeaderTextBlock}" /> - + + VerticalAlignment="Bottom" /> - - - - - - - - - - + Maximum="13" + AutomationProperties.LabeledBy="{Binding ElementName=CurrentMonthHeaderTextBlock}" /> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + VerticalAlignment="Bottom" /> + Minimum="0" + Maximum="32" + AutomationProperties.LabeledBy="{Binding ElementName=CurrentDayHeaderTextBlock}" /> - + + VerticalAlignment="Bottom" /> + Minimum="-1" + Maximum="24" + AutomationProperties.LabeledBy="{Binding ElementName=CurrentHourHeaderTextBlock}" /> - + + VerticalAlignment="Bottom" /> + Minimum="-1" + Maximum="60" + AutomationProperties.LabeledBy="{Binding ElementName=CurrentMinuteHeaderTextBlock}" /> - + + VerticalAlignment="Bottom" /> + Minimum="-1" + Maximum="60" + AutomationProperties.LabeledBy="{Binding ElementName=CurrentSecondHeaderTextBlock}" /> + 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.cs index 065ff501a2..553ca4f509 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( @@ -52,11 +52,12 @@ protected override void OnNavigatedTo(NavigationEventArgs e) { if (long.TryParse(parameters.ClipBoardContent, out long timestamp)) { - ViewModel.Timestamp = timestamp; + ViewModel.CurrentTimestamp = timestamp; } else if (DateTime.TryParse(parameters.ClipBoardContent, out DateTime localDateTime)) { - ViewModel.Timestamp = new DateTimeOffset(localDateTime.ToUniversalTime()).ToUnixTimeSeconds(); + // TODO: + ViewModel.CurrentTimestamp = new DateTimeOffset(localDateTime.ToUniversalTime()).ToUnixTimeSeconds(); } } From a39fb7226875b49ddc576637dd8aa07747490470 Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 4 May 2022 05:21:33 +0900 Subject: [PATCH 03/26] Add info text. --- .../Timestamp/TimestampToolViewModel.cs | 36 ++++- .../Timestamp/TimestampToolPage.xaml | 142 ++++++++++++------ 2 files changed, 133 insertions(+), 45 deletions(-) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 3409dc80d3..13e301dd84 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -35,6 +35,11 @@ public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel private bool _isDaylightSavingTime; private bool _isDSTAmbiguousTime; + private string _dstInfoText = ""; + private string _dstInfoLocalDateTime = ""; + private string _dstInfoUtcDateTime = ""; + private string _dstInfoUtcTicks = ""; + public Type View => typeof(TimestampToolPage); @@ -70,6 +75,29 @@ internal bool IsDSTAmbiguousTime set => SetProperty(ref _isDSTAmbiguousTime, value); } + internal string DSTInfoText + { + get => _dstInfoText; + set => SetProperty(ref _dstInfoText, value); + } + internal string DSTInfoLocalDateTime + { + get => _dstInfoLocalDateTime; + set => SetProperty(ref _dstInfoLocalDateTime, value); + } + + internal string DSTInfoUtcDateTime + { + get => _dstInfoUtcDateTime; + set => SetProperty(ref _dstInfoUtcDateTime, value); + } + + internal string DSTInfoUtcTicks + { + get => _dstInfoUtcTicks; + set => SetProperty(ref _dstInfoUtcTicks, value); + } + private void DSTInfo() { IsDSTAmbiguousTime = false; @@ -79,20 +107,26 @@ private void DSTInfo() if (_currentTimeZone.IsAmbiguousTime(_currentDateTime)) { IsDSTAmbiguousTime = true; + DSTInfoText = Strings.DSTAmbiguousTime; } else if (_currentTimeZone.IsDaylightSavingTime(_currentDateTime)) { IsDaylightSavingTime = true; + DSTInfoText = Strings.DaylightSavingTime; } else if (_currentTimeZone.SupportsDaylightSavingTime) { IsSupportsDST = true; + DSTInfoText = Strings.SupportsDaylightSavingTime; } else { IsDisabledDST = true; + DSTInfoText = Strings.DisabledDaylightSavingTime; } - + DSTInfoLocalDateTime = _currentDateTime.LocalDateTime.ToString(); + DSTInfoUtcDateTime = _currentDateTime.UtcDateTime.ToString(); + DSTInfoUtcTicks = _currentDateTime.UtcTicks.ToString(); } private void SetTimeZoneList() diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 064f6a14bc..780aaf9baa 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -65,18 +65,9 @@ - - - + @@ -84,26 +75,22 @@ Width="Auto" /> - - - - + + AutomationProperties.LabeledBy="{Binding ElementName=CurrentTimestampHeaderTextBlock}"> + + + + + + + + + + + Grid.Column="1" + Spacing="4"> + - + Text="Timezone info" /> + + + + + + + + + + + + + + + + + + + + + + From 77255e12c4444b110fcf804f1a59f7b8623bbbdd Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 4 May 2022 14:21:26 +0900 Subject: [PATCH 04/26] Update UI --- .../Timestamp/TimestampToolViewModel.cs | 45 ++-------- .../Timestamp/TimestampToolPage.xaml | 86 +++++++++---------- 2 files changed, 47 insertions(+), 84 deletions(-) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 13e301dd84..54f60b1579 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -30,12 +30,8 @@ public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel private long _minimumCurrentTimestamp = -62135596800; private long _maximumCurrentTimestamp = 253402300799; - private bool _isSupportsDST; - private bool _isDisabledDST; - private bool _isDaylightSavingTime; - private bool _isDSTAmbiguousTime; - private string _dstInfoText = ""; + private string _dstInfoOffset = ""; private string _dstInfoLocalDateTime = ""; private string _dstInfoUtcDateTime = ""; private string _dstInfoUtcTicks = ""; @@ -51,30 +47,6 @@ internal bool IsInputInvalid set => SetProperty(ref _isInputInvalid, value); } - internal bool IsSupportsDST - { - get => _isSupportsDST; - set => SetProperty(ref _isSupportsDST, value); - } - - internal bool IsDisabledDST - { - get => _isDisabledDST; - set => SetProperty(ref _isDisabledDST, value); - } - - internal bool IsDaylightSavingTime - { - get => _isDaylightSavingTime; - set => SetProperty(ref _isDaylightSavingTime, value); - } - - internal bool IsDSTAmbiguousTime - { - get => _isDSTAmbiguousTime; - set => SetProperty(ref _isDSTAmbiguousTime, value); - } - internal string DSTInfoText { get => _dstInfoText; @@ -86,6 +58,12 @@ internal string DSTInfoLocalDateTime set => SetProperty(ref _dstInfoLocalDateTime, value); } + internal string DSTInfoOffset + { + get => _dstInfoOffset; + set => SetProperty(ref _dstInfoOffset, value); + } + internal string DSTInfoUtcDateTime { get => _dstInfoUtcDateTime; @@ -100,30 +78,23 @@ internal string DSTInfoUtcTicks private void DSTInfo() { - IsDSTAmbiguousTime = false; - IsDaylightSavingTime = false; - IsSupportsDST = false; - IsDisabledDST = false; if (_currentTimeZone.IsAmbiguousTime(_currentDateTime)) { - IsDSTAmbiguousTime = true; DSTInfoText = Strings.DSTAmbiguousTime; } else if (_currentTimeZone.IsDaylightSavingTime(_currentDateTime)) { - IsDaylightSavingTime = true; DSTInfoText = Strings.DaylightSavingTime; } else if (_currentTimeZone.SupportsDaylightSavingTime) { - IsSupportsDST = true; DSTInfoText = Strings.SupportsDaylightSavingTime; } else { - IsDisabledDST = true; DSTInfoText = Strings.DisabledDaylightSavingTime; } + DSTInfoOffset = _currentDateTime.ToString("zzz"); DSTInfoLocalDateTime = _currentDateTime.LocalDateTime.ToString(); DSTInfoUtcDateTime = _currentDateTime.UtcDateTime.ToString(); DSTInfoUtcTicks = _currentDateTime.UtcTicks.ToString(); diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 780aaf9baa..fd76357386 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -34,27 +34,6 @@ Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.CurrentDateTimeTitle}" /> - - - - - @@ -67,7 +46,25 @@ - + + + + + + + @@ -130,26 +127,8 @@ LargeChange="10" Minimum="{x:Bind local:TimestampToolPage.MinimumTimestamp}" Maximum="{x:Bind local:TimestampToolPage.MaximumTimestamp}" - TabIndex="0" AutomationProperties.LabeledBy="{Binding ElementName=CurrentTimestampHeaderTextBlock}" /> - - - - - + Text="Current DateTime info" /> @@ -173,6 +152,7 @@ + + Text="Offset" /> + Text="{x:Bind ViewModel.DSTInfoOffset, Mode=OneWay}" + IsTextSelectionEnabled="True" /> + Text="Local PC" /> + Text="{x:Bind ViewModel.DSTInfoLocalDateTime, Mode=OneWay}" + IsTextSelectionEnabled="True" /> + Text="Utc" /> + Text="{x:Bind ViewModel.DSTInfoUtcDateTime, Mode=OneWay}" + IsTextSelectionEnabled="True" /> + + From c89bee859ecf60cd5a639a727420ebf0483916e0 Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 4 May 2022 15:05:45 +0900 Subject: [PATCH 05/26] Add string keywords. (/*/Timestamp.resw) --- .../impl/DevToys/Strings/cs-CZ/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/de-DE/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/es-AR/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/es-ES/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/fr-FR/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/hu-HU/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/id-ID/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/it-IT/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/ja-JP/Timestamp.resw | 22 +++++++++++++++++-- .../impl/DevToys/Strings/ko-KR/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/pl-PL/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/pt-BR/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/pt-PT/Timestamp.resw | 18 +++++++++++++++ .../impl/DevToys/Strings/ru-RU/Timestamp.resw | 18 +++++++++++++++ .../DevToys/Strings/zh-Hans/Timestamp.resw | 18 +++++++++++++++ .../DevToys/Strings/zh-Hant/Timestamp.resw | 18 +++++++++++++++ 16 files changed, 290 insertions(+), 2 deletions(-) diff --git a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw index 93d8f1bea3..8e77c17862 100644 --- a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw @@ -120,17 +120,32 @@ Unix タイムスタンプ変換ツール + + タイムゾーン指定と日時 + + + タイムゾーン + + + 夏時間 (サマータイム) 適用期間です + - Unix 時間やUTCなどの日時を変換 + Unix 時間や UTC などの日時を変換 + + + 夏時間 (サマータイム) 規則はありません + + + 夏時間の切り替えによる重複が発生しています 時 (24 時間) - 使用できない文字が含まれています + 変換できる範囲を超えています ローカル日時 @@ -154,6 +169,9 @@ + + 夏時間 (サマータイム) 規則があります + タイムスタンプ diff --git a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw index c4edfd6831..253ed85843 100644 --- a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw @@ -120,12 +120,27 @@ 타임스탬프 변환기 + + Current Date and Time + + + Time zone + + + Daylight saving time. + 타임스탬프를 읽기 쉬운 날짜로 변환하거나 반대로 변환합니다. + + There is no daylight saving time. + + + DST Ambiguous time. + 시 (24 시간제) @@ -154,6 +169,9 @@ + + There is daylight saving time. + 타임스탬프 diff --git a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw index 404df2c798..cb1069bba2 100644 --- a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw @@ -120,12 +120,27 @@ Ferramenta de Conversão do Carimbo Temporal + + Current Date and Time + + + Time zone + + + Daylight saving time. + Dia Converte o carimbo temporal em data legível pelo ser humano e vice-versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hora (24 horas) @@ -154,6 +169,9 @@ Segundos + + There is daylight saving time. + Carimbo Temporal diff --git a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw index 1df1790420..ac179b34ef 100644 --- a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw @@ -120,12 +120,27 @@ Timestamp converter tool + + Current Date and Time + + + Time zone + + + Daylight saving time. + Day Convert timestamp to human-readable date and vice versa + + There is no daylight saving time. + + + DST Ambiguous time. + Hour (24 hour) @@ -154,6 +169,9 @@ Seconds + + There is daylight saving time. + Timestamp diff --git a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw index 0307fed2ad..3a14c1d350 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw @@ -120,12 +120,27 @@ 时间戳转换工具 + + Current Date and Time + + + Time zone + + + Daylight saving time. + 将时间戳转换为人类可读的日期,反之亦然 + + There is no daylight saving time. + + + DST Ambiguous time. + 小时(24小时制) @@ -154,6 +169,9 @@ + + There is daylight saving time. + 时间戳 diff --git a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw index 1e0471bad0..886ab0b274 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw @@ -120,12 +120,27 @@ 時間戳轉換工具 + + Current Date and Time + + + Time zone + + + Daylight saving time. + 在時間戳和易讀格式間轉換 + + There is no daylight saving time. + + + DST Ambiguous time. + 時 (24 小時制) @@ -154,6 +169,9 @@ + + There is daylight saving time. + 時間戳 From d91e0f7935779ff446edf4c20ebf7e6b6b3872b1 Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 4 May 2022 15:16:58 +0900 Subject: [PATCH 06/26] Fix UI --- .../Tools/Converters/Timestamp/TimestampToolPage.xaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index fd76357386..37bb64f0a1 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -137,7 +137,8 @@ + Text="Current DateTime info" + Opacity="0" /> @@ -172,7 +173,7 @@ + Text="{x:Bind ViewModel.Strings.LocalDateTime}" /> + Text="{x:Bind ViewModel.Strings.UTCDateTime}" /> Date: Mon, 9 May 2022 16:11:45 +0900 Subject: [PATCH 07/26] Add TimestampToolHelper. --- src/dev/impl/DevToys/DevToys.csproj | 1 + .../DevToys/Helpers/TimestampToolHelper.cs | 118 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs diff --git a/src/dev/impl/DevToys/DevToys.csproj b/src/dev/impl/DevToys/DevToys.csproj index ce32e665f6..d3977eb048 100644 --- a/src/dev/impl/DevToys/DevToys.csproj +++ b/src/dev/impl/DevToys/DevToys.csproj @@ -36,6 +36,7 @@ + diff --git a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs new file mode 100644 index 0000000000..27c5326876 --- /dev/null +++ b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs @@ -0,0 +1,118 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using DevToys.Core; +using DevToys.Models; + +namespace DevToys.Helpers +{ + internal static class TimestampToolHelper + { + internal static class ZoneInfo + { + private static string _utcDisplayName = ""; + private static string _localDisplayName = ""; + private static readonly ReadOnlyCollection _systemTimeZone = TimeZoneInfo.GetSystemTimeZones(); + private static readonly Dictionary _timeZoneCollection = InitTimeZoneCollection(); + + internal static string UtcDisplayName => _utcDisplayName; + + internal static string LocalDisplayName => _localDisplayName; + + internal static List DisplayNames => _timeZoneCollection.Keys.ToList(); + + internal static Dictionary TimeZones => _timeZoneCollection; + + private static Dictionary InitTimeZoneCollection() + { + Dictionary timeZoneCollection = new(); + if (!Regex.IsMatch(_systemTimeZone[0].DisplayName, @"^\(UTC.*\).+$")) + { + // version < .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); + } + /* + else + { + minValue = minValue.Add(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); + } + /* + else + { + maxValue = maxValue.Add(t1.Offset); + } + */ + return TimeZoneInfo.ConvertTime(maxValue, timezone); + } + + } + + } +} From e103b3e69928b19e6f93d9b94b414e72f0b70fc7 Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 11 May 2022 03:09:17 +0900 Subject: [PATCH 08/26] Update TimestampTool --- .../Timestamp/TimestampToolViewModel.cs | 210 ++++-------------- 1 file changed, 49 insertions(+), 161 deletions(-) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 54f60b1579..934062771a 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -2,9 +2,9 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; 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; @@ -16,14 +16,11 @@ namespace DevToys.ViewModels.Tools.Timestamp public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel { private bool _isInputInvalid; - private readonly long _minimumUtcTimestamp = -62135596800; - private readonly long _maximumUtcTimestamp = 253402300799; - internal List TimeZoneDisplayNameCollection = new(); - private readonly Dictionary _timeZoneCollection = new(); - private readonly ReadOnlyCollection _systemTimeZone = TimeZoneInfo.GetSystemTimeZones(); + internal List TimeZoneDisplayNameCollection = TimestampToolHelper.ZoneInfo.DisplayNames; + private readonly Dictionary _timeZoneCollection = TimestampToolHelper.ZoneInfo.TimeZones; private TimeZoneInfo _currentTimeZone = TimeZoneInfo.Utc; - private string _currentTimeZoneDisplayName = TimeZoneInfo.Utc.DisplayName; + private string _currentTimeZoneDisplayName = TimestampToolHelper.ZoneInfo.UtcDisplayName; private double _currentTimestamp; private DateTimeOffset _currentUtcDateTime; private DateTimeOffset _currentDateTime; @@ -36,7 +33,6 @@ public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel private string _dstInfoUtcDateTime = ""; private string _dstInfoUtcTicks = ""; - public Type View => typeof(TimestampToolPage); internal TimestampStrings Strings => LanguageManager.Instance.Timestamp; @@ -52,6 +48,7 @@ internal string DSTInfoText get => _dstInfoText; set => SetProperty(ref _dstInfoText, value); } + internal string DSTInfoLocalDateTime { get => _dstInfoLocalDateTime; @@ -100,17 +97,6 @@ private void DSTInfo() DSTInfoUtcTicks = _currentDateTime.UtcTicks.ToString(); } - private void SetTimeZoneList() - { - foreach (TimeZoneInfo zone in _systemTimeZone) - { - _timeZoneCollection.Add(zone.DisplayName, zone.Id); - TimeZoneDisplayNameCollection.Add(zone.DisplayName); - } - //TimeZoneCollection.Reverse(); - - } - internal string CurrentTimeZoneDisplayName { get => _currentTimeZoneDisplayName; @@ -120,21 +106,12 @@ internal string CurrentTimeZoneDisplayName { _currentTimeZoneDisplayName = value; _currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById(_timeZoneCollection[value]); - if (_currentTimeZone.BaseUtcOffset.TotalSeconds > 0) - { - // UTC+ - _minimumCurrentTimestamp = _minimumUtcTimestamp; - _maximumCurrentTimestamp = _maximumUtcTimestamp - (long)_currentTimeZone.BaseUtcOffset.TotalSeconds; - } - else - { - // UTC- - _minimumCurrentTimestamp = _minimumUtcTimestamp - (long)_currentTimeZone.BaseUtcOffset.TotalSeconds; - _maximumCurrentTimestamp = _maximumUtcTimestamp; - } + _minimumCurrentTimestamp = TimestampToolHelper.TimeZone.SafeMinValue(_currentTimeZone) + .ToUnixTimeSeconds(); + _maximumCurrentTimestamp = TimestampToolHelper.TimeZone.SafeMaxValue(_currentTimeZone) + .ToUnixTimeSeconds(); UpdateCurrentTimestamp(_currentTimestamp); } - } } @@ -144,10 +121,6 @@ internal double CurrentTimestamp set { IsInputInvalid = false; - if (_currentTimestamp == value) - { - return; - } UpdateCurrentTimestamp(value); } } @@ -161,30 +134,12 @@ internal int CurrentYear { return; } - /* - if (CurrentDay > DateTime.DaysInMonth(value, CurrentMonth)) - { - return; - } - */ - try - { - if (IsValidDateTime(value, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) - { - _currentUtcDateTime = _currentUtcDateTime.AddYears(value - _currentDateTime.Year); - } - else - { - IsInputInvalid = true; - return; - } - } - catch + if (!IsValidDateTime(value, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); + CurrentTimestamp = _currentUtcDateTime.AddYears(value - _currentDateTime.Year).ToUnixTimeSeconds(); } } @@ -197,32 +152,12 @@ internal int CurrentMonth { return; } - /* - if (CurrentDay > DateTime.DaysInMonth(CurrentYear, value)) - { - return; - } - */ - try + if (!IsValidDateTime(CurrentYear, value, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) { - if (IsValidDateTime(CurrentYear, value, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) - { - _currentUtcDateTime = _currentUtcDateTime.AddMonths(value - _currentDateTime.Month); - } - else - { - IsInputInvalid = true; - return; - } - } - catch - { - ResetCurrentDateTime(); IsInputInvalid = true; return; - } - CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); + CurrentTimestamp = _currentUtcDateTime.AddMonths(value - _currentDateTime.Month).ToUnixTimeSeconds(); } } @@ -235,30 +170,12 @@ internal int CurrentDay { return; } - /* - if (value > DateTime.DaysInMonth(CurrentYear, CurrentMonth)) - { - return; - } - */ - try - { - if (IsValidDateTime(CurrentYear, CurrentMonth, value, CurrentHour, CurrentMinute, CurrentSecond)) - { - _currentUtcDateTime = _currentUtcDateTime.AddDays(value - _currentDateTime.Day); - } - else - { - IsInputInvalid = true; - return; - } - } - catch + if (!IsValidDateTime(CurrentYear, CurrentMonth, value, CurrentHour, CurrentMinute, CurrentSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); + CurrentTimestamp = _currentUtcDateTime.AddDays(value - _currentDateTime.Day).ToUnixTimeSeconds(); } } @@ -271,24 +188,12 @@ internal int CurrentHour { return; } - try - { - if (IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, value, CurrentMinute, CurrentSecond)) - { - _currentUtcDateTime = _currentUtcDateTime.AddHours(value - _currentDateTime.Hour); - } - else - { - IsInputInvalid = true; - return; - } - } - catch + if (!IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, value, CurrentMinute, CurrentSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); + CurrentTimestamp = _currentUtcDateTime.AddHours(value - _currentDateTime.Hour).ToUnixTimeSeconds(); } } @@ -301,24 +206,12 @@ internal int CurrentMinute { return; } - try - { - if (IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, value, CurrentSecond)) - { - _currentUtcDateTime = _currentUtcDateTime.AddMinutes(value - _currentDateTime.Minute); - } - else - { - IsInputInvalid = true; - return; - } - } - catch + if (!IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, value, CurrentSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); + CurrentTimestamp = _currentUtcDateTime.AddMinutes(value - _currentDateTime.Minute).ToUnixTimeSeconds(); } } @@ -331,24 +224,12 @@ internal int CurrentSecond { return; } - try - { - if (IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, value)) - { - _currentUtcDateTime = _currentUtcDateTime.AddSeconds(value - _currentDateTime.Second); - } - else - { - IsInputInvalid = true; - return; - } - } - catch + if (!IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, value)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.ToUnixTimeSeconds(); + CurrentTimestamp = _currentUtcDateTime.AddSeconds(value - _currentDateTime.Second).ToUnixTimeSeconds(); } } @@ -356,11 +237,10 @@ public TimestampToolViewModel() { PasteCommand = new RelayCommand(ExecutePasteCommand); CopyCommand = new RelayCommand(ExecuteCopyCommand); - SetTimeZoneList(); // Set to the current epoch time. CurrentTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); - CurrentTimeZoneDisplayName = TimeZoneInfo.Local.DisplayName; + CurrentTimeZoneDisplayName = TimestampToolHelper.ZoneInfo.LocalDisplayName; } #region PasteCommand @@ -428,19 +308,25 @@ private void UpdateCurrentTimestamp(double value) { value = 0; } - if (IsValidTimestamp((long)value)) - { - _currentTimestamp = value; - _currentUtcDateTime = TimestampToUtcDateTime(value); - _currentDateTime = TimeZoneInfo.ConvertTime(TimestampToUtcDateTime(value), _currentTimeZone); - DSTInfo(); - ResetCurrentTimestamp(); - ResetCurrentDateTime(); - } - else + if (!IsValidTimestamp((long)value)) { IsInputInvalid = true; + if (value < 0) + { + value = _minimumCurrentTimestamp; + } + else + { + value = _maximumCurrentTimestamp; + } + } + _currentTimestamp = value; + _currentUtcDateTime = TimestampToUtcDateTime(value); + _currentDateTime = TimeZoneInfo.ConvertTime(_currentUtcDateTime, _currentTimeZone); + DSTInfo(); + ResetCurrentTimestamp(); + ResetCurrentDateTime(); } private bool IsValidTimestamp(long value) @@ -449,8 +335,6 @@ private bool IsValidTimestamp(long value) { return false; } - // TODO: - //return TimeZoneInfo.ConvertTime(TimestampToUtcDateTime(value), _currentTimeZone).ToUnixTimeSeconds() == value; return true; } @@ -460,23 +344,27 @@ private bool IsValidDateTime(int Year, int Month, int Day, int Hour, int Minute, { return false; } - TimeSpan offset = _currentTimeZone.BaseUtcOffset; - DateTimeOffset calcDateTime = new(1970, 1, 1, 0, 0, 0, offset); + + DateTimeOffset calcDateTime = TimeZoneInfo.ConvertTime(_currentDateTime, TimeZoneInfo.Utc); + calcDateTime = calcDateTime.AddYears(1970 - calcDateTime.Year); try { - calcDateTime = calcDateTime.AddMonths(Month - 1); - calcDateTime = calcDateTime.AddDays(Day - 1); - calcDateTime = calcDateTime.AddHours(Hour); - calcDateTime = calcDateTime.AddMinutes(Minute); - calcDateTime = calcDateTime.AddSeconds(Second); + calcDateTime = calcDateTime.AddMonths(Month - _currentDateTime.Month); + calcDateTime = calcDateTime.AddDays(Day - _currentDateTime.Day); + calcDateTime = calcDateTime.AddHours(Hour - _currentDateTime.Hour); + calcDateTime = calcDateTime.AddMinutes(Minute - _currentDateTime.Minute); + calcDateTime = calcDateTime.AddSeconds(Second - _currentDateTime.Second); } catch { return false; } + calcDateTime = TimeZoneInfo.ConvertTime(calcDateTime, _currentTimeZone); + TimeSpan offset = calcDateTime.Offset; if (Year + calcDateTime.Year - 1970 is > 1 and < 9999) { + // 0002 ... 9998 return true; } From 4145d27dccc864f71468cd70db45f13fa629e76e Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 11 May 2022 05:02:47 +0900 Subject: [PATCH 09/26] Update Timestamp.resw --- src/dev/impl/DevToys/LanguageManager.cs | 10 ++++++++++ src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/en-US/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw | 6 ++++++ src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw | 6 ++++++ .../Converters/Timestamp/TimestampToolPage.xaml | 13 +++++++------ 19 files changed, 119 insertions(+), 6 deletions(-) diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.cs index eff476953e..ca730e48a4 100644 --- a/src/dev/impl/DevToys/LanguageManager.cs +++ b/src/dev/impl/DevToys/LanguageManager.cs @@ -2690,6 +2690,11 @@ public class TimestampStrings : ObservableObject /// public string MonthTitle => _resources.GetString("MonthTitle"); + /// + /// Gets the resource OffsetTitle. + /// + public string OffsetTitle => _resources.GetString("OffsetTitle"); + /// /// Gets the resource SearchDisplayName. /// @@ -2720,6 +2725,11 @@ public class TimestampStrings : ObservableObject /// public string UTCDateTime => _resources.GetString("UTCDateTime"); + /// + /// Gets the resource UtcTicksTitle. + /// + public string UtcTicksTitle => _resources.GetString("UtcTicksTitle"); + /// /// Gets the resource YearTitle. /// diff --git a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw index 8e77c17862..b6024c8ee0 100644 --- a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw @@ -159,6 +159,9 @@ + + オフセット + Unix タイムスタンプ変換 @@ -178,6 +181,9 @@ UTC (協定世界時) + + UtcTicks 値 + diff --git a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw index 253ed85843..4269091359 100644 --- a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw @@ -159,6 +159,9 @@ + + Offset + Unix 타임스탬프 변환기 @@ -178,6 +181,9 @@ UTC 날짜 및 시간 + + UtcTicks + diff --git a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw index cb1069bba2..b9c0aa3b18 100644 --- a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw @@ -159,6 +159,9 @@ Mês + + Offset + Conversor Carimbo Temporal Unix @@ -178,6 +181,9 @@ Data e Hora UTC + + UtcTicks + Ano diff --git a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw index ac179b34ef..680fb9a715 100644 --- a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw @@ -159,6 +159,9 @@ Month + + Offset + Unix Timestamp Converter @@ -178,6 +181,9 @@ UTC Date and Time + + UtcTicks + Year diff --git a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw index 3a14c1d350..f3d7089e88 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw @@ -159,6 +159,9 @@ + + Offset + Unix 时间戳转换工具 @@ -178,6 +181,9 @@ 世界标准时间(UTC) + + UtcTicks + diff --git a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw index 886ab0b274..1da50bc51e 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw @@ -159,6 +159,9 @@ + + Offset + Unix 時間戳轉換工具 @@ -178,6 +181,9 @@ UTC 日期及時間 + + UtcTicks + diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 37bb64f0a1..c4157b1d00 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -87,9 +87,10 @@ Spacing="8" Margin="0,0,0,8" AutomationProperties.LabeledBy="{Binding ElementName=CurrentTimestampHeaderTextBlock}"> - + + - + @@ -164,7 +165,7 @@ + Text="{x:Bind ViewModel.Strings.OffsetTitle}" /> + Text="{x:Bind ViewModel.Strings.UtcTicksTitle}" /> Date: Wed, 11 May 2022 05:31:46 +0900 Subject: [PATCH 10/26] Cleanup file. --- .../impl/DevToys/Helpers/TimestampToolHelper.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs index 27c5326876..fe52634de0 100644 --- a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs +++ b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs @@ -35,6 +35,8 @@ private static Dictionary InitTimeZoneCollection() if (!Regex.IsMatch(_systemTimeZone[0].DisplayName, @"^\(UTC.*\).+$")) { // version < .Net6 + // This implementation is due to the effect that projects + // for using external tools require .net6 or earlier libraries. foreach (TimeZoneInfo zone in _systemTimeZone) { string displayName = $"(UTC{zone.BaseUtcOffset.Hours:+00;-00;}:{zone.BaseUtcOffset.Minutes:00;00;}) " + zone.DisplayName; @@ -80,12 +82,6 @@ internal static DateTimeOffset SafeMinValue(TimeZoneInfo timezone) { minValue = minValue.Subtract(t1.Offset); } - /* - else - { - minValue = minValue.Add(t1.Offset); - } - */ return TimeZoneInfo.ConvertTime(minValue, timezone); } @@ -103,12 +99,6 @@ internal static DateTimeOffset SafeMaxValue(TimeZoneInfo timezone) { maxValue = maxValue.Subtract(t1.Offset); } - /* - else - { - maxValue = maxValue.Add(t1.Offset); - } - */ return TimeZoneInfo.ConvertTime(maxValue, timezone); } From 06b74d74ff5e0bc9e193b5728b5f8375ab60acd4 Mon Sep 17 00:00:00 2001 From: niyari Date: Sat, 14 May 2022 12:03:13 +0900 Subject: [PATCH 11/26] Added CardStyle. --- .../Timestamp/TimestampToolPage.xaml | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index c4157b1d00..28f3b4b57a 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -132,15 +132,38 @@ - - - + + + + + @@ -199,9 +222,9 @@ Text="{x:Bind ViewModel.DSTInfoUtcTicks, Mode=OneWay}" IsTextSelectionEnabled="True" /> - + + - From 0d277179c7864fdf2fcbe6b25d654cf26097388a Mon Sep 17 00:00:00 2001 From: niyari Date: Sat, 14 May 2022 13:26:53 +0900 Subject: [PATCH 12/26] Stack UI --- .../Timestamp/TimestampToolViewModel.cs | 4 +- .../Timestamp/TimestampToolPage.xaml | 354 +++++++++--------- 2 files changed, 177 insertions(+), 181 deletions(-) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 934062771a..242f1892e8 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -92,8 +92,8 @@ private void DSTInfo() DSTInfoText = Strings.DisabledDaylightSavingTime; } DSTInfoOffset = _currentDateTime.ToString("zzz"); - DSTInfoLocalDateTime = _currentDateTime.LocalDateTime.ToString(); - DSTInfoUtcDateTime = _currentDateTime.UtcDateTime.ToString(); + DSTInfoLocalDateTime = _currentDateTime.LocalDateTime.ToString("yyyy/MM/dd HH:mm:ss"); + DSTInfoUtcDateTime = _currentDateTime.UtcDateTime.ToString("yyyy/MM/dd HH:mm:ss"); DSTInfoUtcTicks = _currentDateTime.UtcTicks.ToString(); } diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 28f3b4b57a..d6861acabe 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -34,199 +34,195 @@ Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.CurrentDateTimeTitle}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Margin="0,0,0,0"> + Width="Auto" /> + + - - - - - - - - - - - - - + Grid.Column="1" + Orientation="Horizontal" + HorizontalAlignment="Right" + Spacing="8" + Margin="0,0,0,8" + AutomationProperties.LabeledBy="{Binding ElementName=CurrentTimestampHeaderTextBlock}"> + + + - - + Spacing="4"> + + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + Date: Sat, 14 May 2022 14:00:02 +0900 Subject: [PATCH 13/26] Fix UI --- .../Timestamp/TimestampToolPage.xaml | 192 +++++++++--------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index d6861acabe..4d123394a4 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -55,102 +55,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b2807f763431535259c8b5d6afffd467025d1349 Mon Sep 17 00:00:00 2001 From: niyari Date: Sat, 14 May 2022 15:32:29 +0900 Subject: [PATCH 14/26] Revert to e45d522. (Timezone info: 509#issuecomment-1126643640 ) --- .../Timestamp/TimestampToolPage.xaml | 192 +++++++++--------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 4d123394a4..d6861acabe 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -55,6 +55,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 1571ed67b44941812605d656f3db1b1d5e21e447 Mon Sep 17 00:00:00 2001 From: niyari Date: Sun, 15 May 2022 03:06:13 +0900 Subject: [PATCH 15/26] Changed UI. Content display by window width. --- .../Timestamp/TimestampToolPage.xaml | 416 ++++++++++++------ 1 file changed, 293 insertions(+), 123 deletions(-) diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index d6861acabe..416e472c63 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -13,6 +13,42 @@ + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 41c29e64a2c1c961b94bd8ae9dd348c31dbfecfe Mon Sep 17 00:00:00 2001 From: niyari Date: Sun, 15 May 2022 03:25:08 +0900 Subject: [PATCH 16/26] Preparation for Conflict Resolution. --- .../Tools/Converters/Timestamp/TimestampToolViewModel.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 242f1892e8..1f346b60fc 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -297,6 +297,9 @@ private void ExecuteCopyCommand() #endregion + #region NowCommand + #endregion + private DateTimeOffset TimestampToUtcDateTime(double value) { return DateTimeOffset.FromUnixTimeSeconds((long)value).UtcDateTime; From c3027e085386e9951c0da5feb1bd31497a9a8eb3 Mon Sep 17 00:00:00 2001 From: niyari Date: Sun, 15 May 2022 14:09:58 +0900 Subject: [PATCH 17/26] Removed compact DateTime info. --- .../Timestamp/TimestampToolPage.xaml | 110 +----------------- 1 file changed, 2 insertions(+), 108 deletions(-) diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index b94889af8b..9f6fa3e4e9 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -19,17 +19,10 @@ + MinWindowWidth="640" /> - - - @@ -93,8 +86,7 @@ + x:Name="Timezoneinfo"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From ddd2d9a64aa5d31a3395b7d915e1392506106ccc Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 18 May 2022 02:27:39 +0900 Subject: [PATCH 18/26] Code cleanup #discussion_r874407747 --- src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs index fe52634de0..6f008d1b1b 100644 --- a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs +++ b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs @@ -4,11 +4,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using DevToys.Core; -using DevToys.Models; namespace DevToys.Helpers { From cf8240bfc54b98ef2e697448eb1af3cffd8027ca Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 18 May 2022 03:01:37 +0900 Subject: [PATCH 19/26] Changed the clipboard datetime string recognition process. --- .../Tools/Converters/Timestamp/TimestampToolPage.xaml.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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.cs index 553ca4f509..79edc28385 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 @@ -54,10 +54,9 @@ protected override void OnNavigatedTo(NavigationEventArgs e) { ViewModel.CurrentTimestamp = timestamp; } - else if (DateTime.TryParse(parameters.ClipBoardContent, out DateTime localDateTime)) + else if (DateTimeOffset.TryParse(parameters.ClipBoardContent, out DateTimeOffset clipboardDateTime)) { - // TODO: - ViewModel.CurrentTimestamp = new DateTimeOffset(localDateTime.ToUniversalTime()).ToUnixTimeSeconds(); + ViewModel.CurrentTimestamp = clipboardDateTime.ToUnixTimeSeconds(); } } From ed79ee62216e9691e9fe94e9cda890158f5fa56a Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 18 May 2022 05:55:46 +0900 Subject: [PATCH 20/26] Added summary. --- .../Timestamp/TimestampToolViewModel.cs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index e24371fc47..86159bbc72 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -37,36 +37,64 @@ public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel internal TimestampStrings Strings => LanguageManager.Instance.Timestamp; + /// + /// Gets or sets true if the DateTimeOffset structure may exceed the settable range. + /// internal bool IsInputInvalid { get => _isInputInvalid; set => SetProperty(ref _isInputInvalid, value); } + /// + /// 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. + /// internal string DSTInfoText { get => _dstInfoText; set => SetProperty(ref _dstInfoText, value); } + /// + /// 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") + /// internal string DSTInfoLocalDateTime { get => _dstInfoLocalDateTime; set => SetProperty(ref _dstInfoLocalDateTime, value); } + /// + /// 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" ) + /// internal string DSTInfoOffset { get => _dstInfoOffset; set => SetProperty(ref _dstInfoOffset, value); } + /// + /// 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") + /// internal string DSTInfoUtcDateTime { get => _dstInfoUtcDateTime; set => SetProperty(ref _dstInfoUtcDateTime, value); } + /// + /// UTCTicks value in DSTInfo block. + /// Gets or sets the string of the specified date and time converted to UTCTicks. + /// internal string DSTInfoUtcTicks { get => _dstInfoUtcTicks; @@ -97,6 +125,11 @@ private void DSTInfo() DSTInfoUtcTicks = _currentDateTime.UtcTicks.ToString(); } + /// + /// Gets or sets the time zone name. + /// This value is essentially the value of TimeZoneInfo.(zone).DisplayName, + /// which is used to reverse lookup the time zone ID supported by the OS(e.g. TimeZoneInfo.Utc.Id). + /// internal string CurrentTimeZoneDisplayName { get => _currentTimeZoneDisplayName; @@ -115,6 +148,10 @@ internal string CurrentTimeZoneDisplayName } } + /// + /// Gets or sets the Unix time. + /// -62135596800 to 253402300799 integer value. + /// internal double CurrentTimestamp { get => _currentTimestamp; @@ -125,6 +162,9 @@ internal double CurrentTimestamp } } + /// + /// Gets or sets the year value. + /// internal int CurrentYear { get => _currentDateTime.Year; @@ -143,6 +183,9 @@ internal int CurrentYear } } + /// + /// Gets or sets the month value. + /// internal int CurrentMonth { get => _currentDateTime.Month; @@ -161,6 +204,9 @@ internal int CurrentMonth } } + /// + /// Gets or sets the day value. + /// internal int CurrentDay { get => _currentDateTime.Day; @@ -179,6 +225,9 @@ internal int CurrentDay } } + /// + /// Gets or sets the hour value. + /// internal int CurrentHour { get => _currentDateTime.Hour; @@ -197,6 +246,9 @@ internal int CurrentHour } } + /// + /// Gets or sets the minute value. + /// internal int CurrentMinute { get => _currentDateTime.Minute; @@ -215,6 +267,9 @@ internal int CurrentMinute } } + /// + /// Gets or sets the second value. + /// internal int CurrentSecond { get => _currentDateTime.Second; From e6a6305fc01230136f5b4df70abc737b4b714af3 Mon Sep 17 00:00:00 2001 From: niyari Date: Wed, 18 May 2022 14:56:27 +0900 Subject: [PATCH 21/26] Fix types. --- src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs | 12 ++++++------ .../Converters/Timestamp/TimestampToolViewModel.cs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs index 6f008d1b1b..1a9ba22691 100644 --- a/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs +++ b/src/dev/impl/DevToys/Helpers/TimestampToolHelper.cs @@ -14,21 +14,21 @@ internal static class ZoneInfo { private static string _utcDisplayName = ""; private static string _localDisplayName = ""; - private static readonly ReadOnlyCollection _systemTimeZone = TimeZoneInfo.GetSystemTimeZones(); - private static readonly Dictionary _timeZoneCollection = InitTimeZoneCollection(); + private static readonly IReadOnlyCollection _systemTimeZone = TimeZoneInfo.GetSystemTimeZones(); + private static readonly IReadOnlyDictionary _timeZoneCollection = InitTimeZoneCollection(); internal static string UtcDisplayName => _utcDisplayName; internal static string LocalDisplayName => _localDisplayName; - internal static List DisplayNames => _timeZoneCollection.Keys.ToList(); + internal static IReadOnlyList DisplayNames => _timeZoneCollection.Keys.ToList(); - internal static Dictionary TimeZones => _timeZoneCollection; + internal static IReadOnlyDictionary TimeZones => _timeZoneCollection; - private static Dictionary InitTimeZoneCollection() + private static IReadOnlyDictionary InitTimeZoneCollection() { Dictionary timeZoneCollection = new(); - if (!Regex.IsMatch(_systemTimeZone[0].DisplayName, @"^\(UTC.*\).+$")) + if (!Regex.IsMatch(_systemTimeZone.ElementAt(0).DisplayName, @"^\(UTC.*\).+$")) { // version < .Net6 // This implementation is due to the effect that projects diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 86159bbc72..382ae97359 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -17,8 +17,8 @@ public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel { private bool _isInputInvalid; - internal List TimeZoneDisplayNameCollection = TimestampToolHelper.ZoneInfo.DisplayNames; - private readonly Dictionary _timeZoneCollection = TimestampToolHelper.ZoneInfo.TimeZones; + internal IReadOnlyList TimeZoneDisplayNameCollection = TimestampToolHelper.ZoneInfo.DisplayNames; + private readonly IReadOnlyDictionary _timeZoneCollection = TimestampToolHelper.ZoneInfo.TimeZones; private TimeZoneInfo _currentTimeZone = TimeZoneInfo.Utc; private string _currentTimeZoneDisplayName = TimestampToolHelper.ZoneInfo.UtcDisplayName; private double _currentTimestamp; @@ -135,10 +135,10 @@ internal string CurrentTimeZoneDisplayName get => _currentTimeZoneDisplayName; set { - if (_timeZoneCollection.ContainsKey(value)) + if (_timeZoneCollection.TryGetValue(value, out string timeZoneID)) { _currentTimeZoneDisplayName = value; - _currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById(_timeZoneCollection[value]); + _currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneID); _minimumCurrentTimestamp = TimestampToolHelper.TimeZone.SafeMinValue(_currentTimeZone) .ToUnixTimeSeconds(); _maximumCurrentTimestamp = TimestampToolHelper.TimeZone.SafeMaxValue(_currentTimeZone) From 6df9e9c7210d5cf3069d12d06100191e74dc54e3 Mon Sep 17 00:00:00 2001 From: niyari Date: Fri, 20 May 2022 02:32:01 +0900 Subject: [PATCH 22/26] Fixed Page.Resources. --- .../Timestamp/TimestampToolPage.xaml | 181 +++++++++--------- 1 file changed, 90 insertions(+), 91 deletions(-) diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 9f6fa3e4e9..8595771272 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -10,6 +10,34 @@ d:DesignHeight="400" d:DesignWidth="600"> + + + + @@ -87,97 +115,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + From 6586285a7a0caa2bbfc2d5d26217955eab4e3e96 Mon Sep 17 00:00:00 2001 From: niyari Date: Sat, 21 May 2022 03:44:00 +0900 Subject: [PATCH 23/26] Change names. --- .../Timestamp/TimestampToolViewModel.cs | 164 +++++++++--------- .../Timestamp/TimestampToolPage.xaml | 18 +- .../Timestamp/TimestampToolPage.xaml.cs | 4 +- 3 files changed, 93 insertions(+), 93 deletions(-) diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs index 382ae97359..2517b7736c 100644 --- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs +++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/Timestamp/TimestampToolViewModel.cs @@ -21,13 +21,13 @@ public sealed class TimestampToolViewModel : ObservableRecipient, IToolViewModel private readonly IReadOnlyDictionary _timeZoneCollection = TimestampToolHelper.ZoneInfo.TimeZones; private TimeZoneInfo _currentTimeZone = TimeZoneInfo.Utc; private string _currentTimeZoneDisplayName = TimestampToolHelper.ZoneInfo.UtcDisplayName; - private double _currentTimestamp; - private DateTimeOffset _currentUtcDateTime; - private DateTimeOffset _currentDateTime; - private long _minimumCurrentTimestamp = -62135596800; - private long _maximumCurrentTimestamp = 253402300799; + private double _timestamp; + private DateTimeOffset _utcDateTime; + private DateTimeOffset _zoneOffsetDateTime; + private long _minimumZoneOffsetTimestamp = -62135596800; + private long _maximumZoneOffsetTimestamp = 253402300799; - private string _dstInfoText = ""; + private string _dstInfoDSTMessage = ""; private string _dstInfoOffset = ""; private string _dstInfoLocalDateTime = ""; private string _dstInfoUtcDateTime = ""; @@ -52,10 +52,10 @@ internal bool IsInputInvalid /// daylight saving time support, in daylight saving time, or ambiguous time /// for a given time zone. /// - internal string DSTInfoText + internal string DSTInfoMessage { - get => _dstInfoText; - set => SetProperty(ref _dstInfoText, value); + get => _dstInfoDSTMessage; + set => SetProperty(ref _dstInfoDSTMessage, value); } /// @@ -72,9 +72,9 @@ internal string DSTInfoLocalDateTime /// /// 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" ) + /// (e.g. "+09:00") /// - internal string DSTInfoOffset + internal string DSTInfoOffsetValue { get => _dstInfoOffset; set => SetProperty(ref _dstInfoOffset, value); @@ -103,32 +103,32 @@ internal string DSTInfoUtcTicks private void DSTInfo() { - if (_currentTimeZone.IsAmbiguousTime(_currentDateTime)) + if (_currentTimeZone.IsAmbiguousTime(_zoneOffsetDateTime)) { - DSTInfoText = Strings.DSTAmbiguousTime; + DSTInfoMessage = Strings.DSTAmbiguousTime; } - else if (_currentTimeZone.IsDaylightSavingTime(_currentDateTime)) + else if (_currentTimeZone.IsDaylightSavingTime(_zoneOffsetDateTime)) { - DSTInfoText = Strings.DaylightSavingTime; + DSTInfoMessage = Strings.DaylightSavingTime; } else if (_currentTimeZone.SupportsDaylightSavingTime) { - DSTInfoText = Strings.SupportsDaylightSavingTime; + DSTInfoMessage = Strings.SupportsDaylightSavingTime; } else { - DSTInfoText = Strings.DisabledDaylightSavingTime; + DSTInfoMessage = Strings.DisabledDaylightSavingTime; } - DSTInfoOffset = _currentDateTime.ToString("zzz"); - DSTInfoLocalDateTime = _currentDateTime.LocalDateTime.ToString("yyyy/MM/dd HH:mm:ss"); - DSTInfoUtcDateTime = _currentDateTime.UtcDateTime.ToString("yyyy/MM/dd HH:mm:ss"); - DSTInfoUtcTicks = _currentDateTime.UtcTicks.ToString(); + 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(); } /// /// Gets or sets the time zone name. - /// This value is essentially the value of TimeZoneInfo.(zone).DisplayName, - /// which is used to reverse lookup the time zone ID supported by the OS(e.g. TimeZoneInfo.Utc.Id). + /// 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"). /// internal string CurrentTimeZoneDisplayName { @@ -139,152 +139,152 @@ internal string CurrentTimeZoneDisplayName { _currentTimeZoneDisplayName = value; _currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneID); - _minimumCurrentTimestamp = TimestampToolHelper.TimeZone.SafeMinValue(_currentTimeZone) + _minimumZoneOffsetTimestamp = TimestampToolHelper.TimeZone.SafeMinValue(_currentTimeZone) .ToUnixTimeSeconds(); - _maximumCurrentTimestamp = TimestampToolHelper.TimeZone.SafeMaxValue(_currentTimeZone) + _maximumZoneOffsetTimestamp = TimestampToolHelper.TimeZone.SafeMaxValue(_currentTimeZone) .ToUnixTimeSeconds(); - UpdateCurrentTimestamp(_currentTimestamp); + UpdateZoneOffsetTimestamp(_timestamp); } } } /// /// Gets or sets the Unix time. - /// -62135596800 to 253402300799 integer value. + /// -62135596800 (0001-01-01T00:00:00Z) to 253402300799 (9999-12-31T23:59:59Z) integer value. /// - internal double CurrentTimestamp + internal double Timestamp { - get => _currentTimestamp; + get => _timestamp; set { IsInputInvalid = false; - UpdateCurrentTimestamp(value); + UpdateZoneOffsetTimestamp(value); } } /// /// Gets or sets the year value. /// - internal int CurrentYear + internal int ZoneOffsetYear { - get => _currentDateTime.Year; + get => _zoneOffsetDateTime.Year; set { if (value < 1) // empty = -2147483648 { return; } - if (!IsValidDateTime(value, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) + if (!IsValidDateTime(value, ZoneOffsetMonth, ZoneOffsetDay, ZoneOffsetHour, ZoneOffsetMinute, ZoneOffsetSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.AddYears(value - _currentDateTime.Year).ToUnixTimeSeconds(); + Timestamp = _utcDateTime.AddYears(value - _zoneOffsetDateTime.Year).ToUnixTimeSeconds(); } } /// /// Gets or sets the month value. /// - internal int CurrentMonth + internal int ZoneOffsetMonth { - get => _currentDateTime.Month; + get => _zoneOffsetDateTime.Month; set { if (value < 0) // empty = -2147483648 { return; } - if (!IsValidDateTime(CurrentYear, value, CurrentDay, CurrentHour, CurrentMinute, CurrentSecond)) + if (!IsValidDateTime(ZoneOffsetYear, value, ZoneOffsetDay, ZoneOffsetHour, ZoneOffsetMinute, ZoneOffsetSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.AddMonths(value - _currentDateTime.Month).ToUnixTimeSeconds(); + Timestamp = _utcDateTime.AddMonths(value - _zoneOffsetDateTime.Month).ToUnixTimeSeconds(); } } /// /// Gets or sets the day value. /// - internal int CurrentDay + internal int ZoneOffsetDay { - get => _currentDateTime.Day; + get => _zoneOffsetDateTime.Day; set { if (value < 0) // empty = -2147483648 { return; } - if (!IsValidDateTime(CurrentYear, CurrentMonth, value, CurrentHour, CurrentMinute, CurrentSecond)) + if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, value, ZoneOffsetHour, ZoneOffsetMinute, ZoneOffsetSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.AddDays(value - _currentDateTime.Day).ToUnixTimeSeconds(); + Timestamp = _utcDateTime.AddDays(value - _zoneOffsetDateTime.Day).ToUnixTimeSeconds(); } } /// /// Gets or sets the hour value. /// - internal int CurrentHour + internal int ZoneOffsetHour { - get => _currentDateTime.Hour; + get => _zoneOffsetDateTime.Hour; set { if (value < -1) // empty = -2147483648 { return; } - if (!IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, value, CurrentMinute, CurrentSecond)) + if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, ZoneOffsetDay, value, ZoneOffsetMinute, ZoneOffsetSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.AddHours(value - _currentDateTime.Hour).ToUnixTimeSeconds(); + Timestamp = _utcDateTime.AddHours(value - _zoneOffsetDateTime.Hour).ToUnixTimeSeconds(); } } /// /// Gets or sets the minute value. /// - internal int CurrentMinute + internal int ZoneOffsetMinute { - get => _currentDateTime.Minute; + get => _zoneOffsetDateTime.Minute; set { if (value < -1) // empty = -2147483648 { return; } - if (!IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, value, CurrentSecond)) + if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, ZoneOffsetDay, ZoneOffsetHour, value, ZoneOffsetSecond)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.AddMinutes(value - _currentDateTime.Minute).ToUnixTimeSeconds(); + Timestamp = _utcDateTime.AddMinutes(value - _zoneOffsetDateTime.Minute).ToUnixTimeSeconds(); } } /// /// Gets or sets the second value. /// - internal int CurrentSecond + internal int ZoneOffsetSecond { - get => _currentDateTime.Second; + get => _zoneOffsetDateTime.Second; set { if (value < -1) // empty = -2147483648 { return; } - if (!IsValidDateTime(CurrentYear, CurrentMonth, CurrentDay, CurrentHour, CurrentMinute, value)) + if (!IsValidDateTime(ZoneOffsetYear, ZoneOffsetMonth, ZoneOffsetDay, ZoneOffsetHour, ZoneOffsetMinute, value)) { IsInputInvalid = true; return; } - CurrentTimestamp = _currentUtcDateTime.AddSeconds(value - _currentDateTime.Second).ToUnixTimeSeconds(); + Timestamp = _utcDateTime.AddSeconds(value - _zoneOffsetDateTime.Second).ToUnixTimeSeconds(); } } @@ -295,7 +295,7 @@ public TimestampToolViewModel() NowCommand = new RelayCommand(ExecuteNowCommand); // Set to the current epoch time. - CurrentTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); + Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); CurrentTimeZoneDisplayName = TimestampToolHelper.ZoneInfo.LocalDisplayName; } @@ -317,7 +317,7 @@ private async void ExecutePasteCommand() if (long.TryParse(text, out long value)) { - CurrentTimestamp = value; + Timestamp = value; } } catch (Exception ex) @@ -340,7 +340,7 @@ private void ExecuteCopyCommand() { RequestedOperation = DataPackageOperation.Copy }; - data.SetText(CurrentTimestamp.ToString()); + data.SetText(Timestamp.ToString()); Clipboard.SetContentWithOptions(data, new ClipboardContentOptions() { IsAllowedInHistory = true, IsRoamable = true }); Clipboard.Flush(); // This method allows the content to remain available after the application shuts down. @@ -358,7 +358,7 @@ private void ExecuteCopyCommand() private void ExecuteNowCommand() { - CurrentTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); + Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); } #endregion @@ -368,7 +368,7 @@ private DateTimeOffset TimestampToUtcDateTime(double value) return DateTimeOffset.FromUnixTimeSeconds((long)value).UtcDateTime; } - private void UpdateCurrentTimestamp(double value) + private void UpdateZoneOffsetTimestamp(double value) { if (double.IsNaN(value)) { @@ -379,25 +379,25 @@ private void UpdateCurrentTimestamp(double value) IsInputInvalid = true; if (value < 0) { - value = _minimumCurrentTimestamp; + value = _minimumZoneOffsetTimestamp; } else { - value = _maximumCurrentTimestamp; + value = _maximumZoneOffsetTimestamp; } } - _currentTimestamp = value; - _currentUtcDateTime = TimestampToUtcDateTime(value); - _currentDateTime = TimeZoneInfo.ConvertTime(_currentUtcDateTime, _currentTimeZone); + _timestamp = value; + _utcDateTime = TimestampToUtcDateTime(value); + _zoneOffsetDateTime = TimeZoneInfo.ConvertTime(_utcDateTime, _currentTimeZone); DSTInfo(); - ResetCurrentTimestamp(); - ResetCurrentDateTime(); + ResetZoneOffsetTimestamp(); + ResetZoneOffsetDateTime(); } private bool IsValidTimestamp(long value) { - if (value < _minimumCurrentTimestamp || value > _maximumCurrentTimestamp) + if (value < _minimumZoneOffsetTimestamp || value > _maximumZoneOffsetTimestamp) { return false; } @@ -411,15 +411,15 @@ private bool IsValidDateTime(int Year, int Month, int Day, int Hour, int Minute, return false; } - DateTimeOffset calcDateTime = TimeZoneInfo.ConvertTime(_currentDateTime, TimeZoneInfo.Utc); + DateTimeOffset calcDateTime = TimeZoneInfo.ConvertTime(_zoneOffsetDateTime, TimeZoneInfo.Utc); calcDateTime = calcDateTime.AddYears(1970 - calcDateTime.Year); try { - calcDateTime = calcDateTime.AddMonths(Month - _currentDateTime.Month); - calcDateTime = calcDateTime.AddDays(Day - _currentDateTime.Day); - calcDateTime = calcDateTime.AddHours(Hour - _currentDateTime.Hour); - calcDateTime = calcDateTime.AddMinutes(Minute - _currentDateTime.Minute); - calcDateTime = calcDateTime.AddSeconds(Second - _currentDateTime.Second); + 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 { @@ -475,19 +475,19 @@ private bool IsValidDateTime(int Year, int Month, int Day, int Hour, int Minute, return true; } - private void ResetCurrentDateTime() + private void ResetZoneOffsetDateTime() { - OnPropertyChanged(nameof(CurrentYear)); - OnPropertyChanged(nameof(CurrentMonth)); - OnPropertyChanged(nameof(CurrentDay)); - OnPropertyChanged(nameof(CurrentHour)); - OnPropertyChanged(nameof(CurrentMinute)); - OnPropertyChanged(nameof(CurrentSecond)); + OnPropertyChanged(nameof(ZoneOffsetYear)); + OnPropertyChanged(nameof(ZoneOffsetMonth)); + OnPropertyChanged(nameof(ZoneOffsetDay)); + OnPropertyChanged(nameof(ZoneOffsetHour)); + OnPropertyChanged(nameof(ZoneOffsetMinute)); + OnPropertyChanged(nameof(ZoneOffsetSecond)); } - private void ResetCurrentTimestamp() + private void ResetZoneOffsetTimestamp() { - OnPropertyChanged(nameof(CurrentTimestamp)); + 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.xaml index 8595771272..6a2a1ee911 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -139,7 +139,7 @@ Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" - Text="{x:Bind ViewModel.DSTInfoText, Mode=OneWay}" /> + Text="{x:Bind ViewModel.DSTInfoMessage, Mode=OneWay}" /> Date: Sat, 21 May 2022 03:56:33 +0900 Subject: [PATCH 24/26] Remove Strings.CurrentDateTimeTitle --- src/dev/impl/DevToys/LanguageManager.cs | 5 ----- src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/en-US/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw | 3 --- src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw | 3 --- .../Views/Tools/Converters/Timestamp/TimestampToolPage.xaml | 6 ------ 19 files changed, 62 deletions(-) diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.cs index d2e1fb0254..630736e0f8 100644 --- a/src/dev/impl/DevToys/LanguageManager.cs +++ b/src/dev/impl/DevToys/LanguageManager.cs @@ -2630,11 +2630,6 @@ public class TimestampStrings : ObservableObject /// public string AccessibleName => _resources.GetString("AccessibleName"); - /// - /// Gets the resource CurrentDateTimeTitle. - /// - public string CurrentDateTimeTitle => _resources.GetString("CurrentDateTimeTitle"); - /// /// Gets the resource CurrentTimeZone. /// diff --git a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw index d2f3f015c3..c341c7ae1a 100644 --- a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw @@ -120,9 +120,6 @@ Convertitore Unix Timestamp - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw index b6024c8ee0..de87e25cd1 100644 --- a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw @@ -120,9 +120,6 @@ Unix タイムスタンプ変換ツール - - タイムゾーン指定と日時 - タイムゾーン diff --git a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw index 4269091359..4f6b4a19f9 100644 --- a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw @@ -120,9 +120,6 @@ 타임스탬프 변환기 - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw index b9c0aa3b18..4e36860f71 100644 --- a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw @@ -120,9 +120,6 @@ Ferramenta de Conversão do Carimbo Temporal - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw index 680fb9a715..e3aa16dd01 100644 --- a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw @@ -120,9 +120,6 @@ Timestamp converter tool - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw index f3d7089e88..1b464c8acd 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw @@ -120,9 +120,6 @@ 时间戳转换工具 - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw index 1da50bc51e..97ff00882e 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw @@ -120,9 +120,6 @@ 時間戳轉換工具 - - Current Date and Time - Time zone diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 6a2a1ee911..8accdb48f0 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -85,12 +85,6 @@ Message="{x:Bind ViewModel.Strings.InvalidValue}" IsOpen="{x:Bind ViewModel.IsInputInvalid, Mode=OneWay}" IsClosable="False" /> - - - From 3800905f88550d2e05119075b63c5f53abaff1e4 Mon Sep 17 00:00:00 2001 From: niyari Date: Sat, 21 May 2022 15:16:39 +0900 Subject: [PATCH 25/26] Change names. --- src/dev/impl/DevToys/LanguageManager.cs | 4 +- .../impl/DevToys/Strings/cs-CZ/Timestamp.resw | 2 +- .../impl/DevToys/Strings/de-DE/Timestamp.resw | 2 +- .../impl/DevToys/Strings/en-US/Timestamp.resw | 2 +- .../impl/DevToys/Strings/es-AR/Timestamp.resw | 2 +- .../impl/DevToys/Strings/es-ES/Timestamp.resw | 2 +- .../impl/DevToys/Strings/fr-FR/Timestamp.resw | 2 +- .../impl/DevToys/Strings/hu-HU/Timestamp.resw | 2 +- .../impl/DevToys/Strings/id-ID/Timestamp.resw | 2 +- .../impl/DevToys/Strings/it-IT/Timestamp.resw | 2 +- .../impl/DevToys/Strings/ja-JP/Timestamp.resw | 2 +- .../impl/DevToys/Strings/ko-KR/Timestamp.resw | 2 +- .../impl/DevToys/Strings/pl-PL/Timestamp.resw | 2 +- .../impl/DevToys/Strings/pt-BR/Timestamp.resw | 2 +- .../impl/DevToys/Strings/pt-PT/Timestamp.resw | 2 +- .../impl/DevToys/Strings/ru-RU/Timestamp.resw | 2 +- .../DevToys/Strings/zh-Hans/Timestamp.resw | 2 +- .../DevToys/Strings/zh-Hant/Timestamp.resw | 2 +- .../Timestamp/TimestampToolPage.xaml | 54 ++++++++++--------- 19 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.cs index 630736e0f8..9291200314 100644 --- a/src/dev/impl/DevToys/LanguageManager.cs +++ b/src/dev/impl/DevToys/LanguageManager.cs @@ -2631,9 +2631,9 @@ public class TimestampStrings : ObservableObject public string AccessibleName => _resources.GetString("AccessibleName"); /// - /// Gets the resource CurrentTimeZone. + /// Gets the resource TimeZoneTitle. /// - public string CurrentTimeZone => _resources.GetString("CurrentTimeZone"); + public string TimeZoneTitle => _resources.GetString("TimeZoneTitle"); /// /// Gets the resource DaylightSavingTime. diff --git a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/cs-CZ/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/de-DE/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/en-US/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-AR/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/es-ES/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/fr-FR/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/hu-HU/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/id-ID/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw index c341c7ae1a..db2b942079 100644 --- a/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/it-IT/Timestamp.resw @@ -120,7 +120,7 @@ Convertitore Unix Timestamp - + Time zone diff --git a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw index de87e25cd1..1243f1132e 100644 --- a/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ja-JP/Timestamp.resw @@ -120,7 +120,7 @@ Unix タイムスタンプ変換ツール - + タイムゾーン diff --git a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw index 4f6b4a19f9..9004511660 100644 --- a/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ko-KR/Timestamp.resw @@ -120,7 +120,7 @@ 타임스탬프 변환기 - + Time zone diff --git a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pl-PL/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-BR/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw index 4e36860f71..74966d64ee 100644 --- a/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/pt-PT/Timestamp.resw @@ -120,7 +120,7 @@ Ferramenta de Conversão do Carimbo Temporal - + Time zone diff --git a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw index e3aa16dd01..ded72ad0b8 100644 --- a/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/ru-RU/Timestamp.resw @@ -120,7 +120,7 @@ Timestamp converter tool - + Time zone diff --git a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw index 1b464c8acd..7e12211376 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hans/Timestamp.resw @@ -120,7 +120,7 @@ 时间戳转换工具 - + Time zone diff --git a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw index 97ff00882e..f81f2ef0e8 100644 --- a/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw +++ b/src/dev/impl/DevToys/Strings/zh-Hant/Timestamp.resw @@ -120,7 +120,7 @@ 時間戳轉換工具 - + Time zone diff --git a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml index 8accdb48f0..5a586541c6 100644 --- a/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml +++ b/src/dev/impl/DevToys/Views/Tools/Converters/Timestamp/TimestampToolPage.xaml @@ -37,7 +37,7 @@ Value="{ThemeResource ExpanderHeaderBackground}" /> - + @@ -52,17 +52,17 @@ @@ -91,7 +91,7 @@ + AutomationProperties.LabeledBy="{Binding ElementName=TimestampHeaderTextBlock}">