Skip to content

Commit

Permalink
fix: Setting hours on Calendar does not work correctly
Browse files Browse the repository at this point in the history
This is still not ideal and does not correctly consider AM/PM
  • Loading branch information
MartinZikmund committed Jan 18, 2024
1 parent 9b84510 commit 7ac83d3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/Uno.UWP/Globalization/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ private static string GetCalendarSystem(_Calendar calendar)
global::System.Globalization.UmAlQuraCalendar _ => CalendarIdentifiers.UmAlQura,
global::System.Globalization.PersianCalendar _ => CalendarIdentifiers.Persian,
global::System.Globalization.ChineseLunisolarCalendar _ => CalendarIdentifiers.ChineseLunar,
// Not supported by UWP as of 2019-05-23
// https://docs.microsoft.com/en-us/uwp/api/windows.globalization.calendaridentifiers
global::System.Globalization.TaiwanLunisolarCalendar _ => CalendarIdentifiers.TaiwanLunar,
global::System.Globalization.KoreanLunisolarCalendar _ => CalendarIdentifiers.KoreanLunar,
global::System.Globalization.JapaneseLunisolarCalendar _ => CalendarIdentifiers.JapaneseLunar,
// Missing support in System.Globalization for VietnameseLunar calendar.
// case CalendarIdentifiers.VietnameseLunar: return new global::System.Globalization.VietnameseLunarCalendar();
// case CalendarIdentifiers.TaiwanLunar: return new global::System.Globalization.TaiwanLunarCalendar();
// case CalendarIdentifiers.KoreanLunar: return new global::System.Globalization.KoreanLunarCalendar();
// case CalendarIdentifiers.JapaneseLunar: return new global::System.Globalization.JapaneseLunarCalendar();
_ => throw new ArgumentException(nameof(calendar), $"Unknown calendar {calendar}."),
};
}
Expand Down Expand Up @@ -231,7 +230,17 @@ public int Hour
}
}

set => AddHours(value - Hour);
set
{
if (value == 12 && _clock == ClockIdentifiers.TwelveHour)
{
AddHours(-Hour);
}
else
{
AddHours(value - Hour);
}
}
}

public int Minute
Expand Down

0 comments on commit 7ac83d3

Please sign in to comment.