Skip to content

Commit

Permalink
Merge pull request #11 from arpadbarta/feature/adds-text-only-format
Browse files Browse the repository at this point in the history
Feature/adds text only format
  • Loading branch information
arpadbarta authored Sep 24, 2023
2 parents 8a3191f + c281a59 commit 60dbad4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Time.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity
Name="2766ABDEV.DateTime"
Publisher="CN=2C978AE4-500A-46CC-8E4F-229072C4E4D2"
Version="2.3.0.0" />
Version="2.4.0.0" />

<Properties>
<DisplayName>Date &amp; Time</DisplayName>
Expand Down
6 changes: 4 additions & 2 deletions Time/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,12 @@
</ComboBox>

<TextBlock Text="{x:Static translations:Resource.PrefixLabel}"/>
<TextBox Text="{Binding Prefix, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Text="{Binding Prefix, UpdateSourceTrigger=PropertyChanged}"
AcceptsReturn="True"/>

<TextBlock Text="{x:Static translations:Resource.SuffixLabel}"/>
<TextBox Text="{Binding Suffix, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Text="{Binding Suffix, UpdateSourceTrigger=PropertyChanged}"
AcceptsReturn="True"/>
</StackPanel>
</DataTemplate>
</ContentControl.ContentTemplate>
Expand Down
2 changes: 1 addition & 1 deletion Time/Time.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Company>AB Dev</Company>
<Description>Just shows the time and date. That is all.</Description>
<Platforms>x86;x64</Platforms>
<Version>2.3.0.0</Version>
<Version>2.4.0.0</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
</PropertyGroup>
Expand Down
9 changes: 9 additions & 0 deletions Time/Translations/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Time/Translations/Resource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ will result in:
<data name="SuffixLabel" xml:space="preserve">
<value>Suffix (text shown after the segment)</value>
</data>
<data name="TextOnlyFormatLabel" xml:space="preserve">
<value>Text only</value>
</data>
<data name="TimeLabel" xml:space="preserve">
<value>Time</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions Time/ViewModels/SegmentViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public record SegmentConfiguration
public class SegmentViewModel : ObservableObject
{
private const string CustomFormat = "custom-format";
private const string TextOnly = "text-only";
private const string LocalZone = "local";

private static readonly FormatDefinition[] _formats;
Expand Down Expand Up @@ -125,6 +126,7 @@ static SegmentViewModel()
new FormatDefinition(Resource.ShortDateLabel, Resource.DateLabel, "d"),
new FormatDefinition(Resource.LongDateLabel, Resource.DateLabel, "D"),
new FormatDefinition(Resource.CustomFormatLabel, Resource.CustomFormatLabel, CustomFormat),
new FormatDefinition(Resource.TextOnlyFormatLabel, Resource.CustomFormatLabel, TextOnly),
};
}

Expand Down Expand Up @@ -157,6 +159,13 @@ public void Update(DateTime dateTime)
{
ArgumentNullException.ThrowIfNull(dateTime);

if (Format == TextOnly)
{
Content = string.Empty;

return;
}

try
{
Content = TimeZoneInfo.ConvertTime(dateTime, _selectedTimeZoneInfo).ToString(Format);
Expand Down

0 comments on commit 60dbad4

Please sign in to comment.