mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-07 05:31:09 -07:00
Fix issue with Date diff when it includes a Daylight Saving Time (#193)
The application uses local time to calculate the number of days between 2 dates. If a Daylight Saving Time takes place during this period of time (only Clocks Forward 2am->3am), the application will miss 1 day and fail to calculate the number of days/weeks/months between the 2 dates. image Description of the changes: DateCalculationEngine uses local time to modify dates, however, AddDays, AddWeeks,... won't add 24 hours or 7 days if DST happens between the 2 dates, but instead add ~23.9/24.1 hours or ~6.9/7.1 days (depends if it's the DST clock backward or clock forward). When the DST is clock forward, DateCalculationEngine will miss one day. Solution use UTC dates to calculate date difference. Extra Fix: use calendar->FirstPeriodInThisDay and calendar->FirstHourInThisPeriod in ClipTime (else it will set the time to 12PM (noon) in some regions. replace OBSERVABLE_PROPERTY_RW by OBSERVABLE_PROPERTY_R when possible. remove the definition of CheckClipTimeSameDay (implementation missing) How changes were validated: Tested manually with different regions (FR, US, ES, JP). Fixes #178
This commit is contained in:
parent
e40791d7ad
commit
cd7c266a6b
4 changed files with 76 additions and 32 deletions
|
@ -23,8 +23,8 @@ namespace CalculatorApp
|
|||
// Input Properties
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsDateDiffMode);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsAddMode);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsDiffInDays); // If diff is only in days or the dates are the same,
|
||||
// then show only one result and avoid redundancy
|
||||
OBSERVABLE_PROPERTY_R(bool, IsDiffInDays); // If diff is only in days or the dates are the same,
|
||||
// then show only one result and avoid redundancy
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(int, DaysOffset);
|
||||
OBSERVABLE_PROPERTY_RW(int, MonthsOffset);
|
||||
|
@ -82,11 +82,11 @@ namespace CalculatorApp
|
|||
}
|
||||
|
||||
// Output Properties
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, StrDateDiffResult);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, StrDateDiffResultAutomationName);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, StrDateDiffResultInDays);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, StrDateResult);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, StrDateResultAutomationName);
|
||||
OBSERVABLE_PROPERTY_R(Platform::String^, StrDateDiffResult);
|
||||
OBSERVABLE_PROPERTY_R(Platform::String^, StrDateDiffResultAutomationName);
|
||||
OBSERVABLE_PROPERTY_R(Platform::String^, StrDateDiffResultInDays);
|
||||
OBSERVABLE_PROPERTY_R(Platform::String^, StrDateResult);
|
||||
OBSERVABLE_PROPERTY_R(Platform::String^, StrDateResultAutomationName);
|
||||
|
||||
COMMAND_FOR_METHOD(CopyCommand, DateCalculatorViewModel::OnCopyCommand);
|
||||
|
||||
|
@ -104,8 +104,6 @@ namespace CalculatorApp
|
|||
Platform::String^ GetLocalizedNumberString(int value) const;
|
||||
static Windows::Foundation::DateTime ClipTime(Windows::Foundation::DateTime dateTime);
|
||||
|
||||
static void CheckClipTimeSameDay(Windows::Globalization::Calendar^ reference);
|
||||
|
||||
property bool IsOutOfBound
|
||||
{
|
||||
bool get() { return m_isOutOfBound; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue