mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Merge branch 'master' into fix-code-style
This commit is contained in:
commit
adc430267c
6 changed files with 122 additions and 69 deletions
|
@ -15,10 +15,6 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- checkout: none
|
- checkout: none
|
||||||
|
|
||||||
- powershell: Set-DisplayResolution -Width 1920 -Height 1080 -Force
|
|
||||||
displayName: Set resolution to 1920x1080
|
|
||||||
continueOnError: true
|
|
||||||
|
|
||||||
- task: DownloadBuildArtifacts@0
|
- task: DownloadBuildArtifacts@0
|
||||||
displayName: Download AppxBundle and CalculatorUITests
|
displayName: Download AppxBundle and CalculatorUITests
|
||||||
inputs:
|
inputs:
|
||||||
|
@ -39,8 +35,10 @@ jobs:
|
||||||
filePath: $(Build.ArtifactStagingDirectory)/drop/Release/${{ parameters.platform }}/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Add-AppDevPackage.ps1
|
filePath: $(Build.ArtifactStagingDirectory)/drop/Release/${{ parameters.platform }}/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Add-AppDevPackage.ps1
|
||||||
arguments: -Force
|
arguments: -Force
|
||||||
|
|
||||||
- powershell: Start-Process -FilePath "C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe" -Verb RunAs
|
- task: WinAppDriver.winappdriver-pipelines-task.winappdriver-pipelines-task.Windows Application Driver@0
|
||||||
displayName: Start WinAppDriver
|
displayName: 'WinAppDriver - Start'
|
||||||
|
inputs:
|
||||||
|
AgentResolution: 1080p
|
||||||
|
|
||||||
- task: VSTest@2
|
- task: VSTest@2
|
||||||
displayName: Run CalculatorUITests
|
displayName: Run CalculatorUITests
|
||||||
|
@ -50,3 +48,8 @@ jobs:
|
||||||
runSettingsFile: $(Build.ArtifactStagingDirectory)/drop/Release/${{ parameters.platform }}/publish/CalculatorUITests.runsettings
|
runSettingsFile: $(Build.ArtifactStagingDirectory)/drop/Release/${{ parameters.platform }}/publish/CalculatorUITests.runsettings
|
||||||
platform: ${{ parameters.platform }}
|
platform: ${{ parameters.platform }}
|
||||||
configuration: Release
|
configuration: Release
|
||||||
|
|
||||||
|
- task: WinAppDriver.winappdriver-pipelines-task.winappdriver-pipelines-task.Windows Application Driver@0
|
||||||
|
displayName: 'WinAppDriver - Stop'
|
||||||
|
inputs:
|
||||||
|
OperationType: Stop
|
|
@ -123,7 +123,7 @@
|
||||||
<AppxPackageTestDir>@(AppxBundleOutput->'%(RootDir)%(Directory)')</AppxPackageTestDir>
|
<AppxPackageTestDir>@(AppxBundleOutput->'%(RootDir)%(Directory)')</AppxPackageTestDir>
|
||||||
<UniversalTestCustomMacros Condition="'$(Configuration)'=='Debug'">$(UniversalTestCustomMacros)AppxPackageVCLibsDependency=$(AppxPackageTestDir)Dependencies\$(PlatformTarget)\Microsoft.VCLibs.$(PlatformTarget).Debug.14.00.appx;</UniversalTestCustomMacros>
|
<UniversalTestCustomMacros Condition="'$(Configuration)'=='Debug'">$(UniversalTestCustomMacros)AppxPackageVCLibsDependency=$(AppxPackageTestDir)Dependencies\$(PlatformTarget)\Microsoft.VCLibs.$(PlatformTarget).Debug.14.00.appx;</UniversalTestCustomMacros>
|
||||||
<UniversalTestCustomMacros Condition="'$(Configuration)'=='Release'">$(UniversalTestCustomMacros)AppxPackageVCLibsDependency=$(AppxPackageTestDir)Dependencies\$(PlatformTarget)\Microsoft.VCLibs.$(PlatformTarget).14.00.appx;</UniversalTestCustomMacros>
|
<UniversalTestCustomMacros Condition="'$(Configuration)'=='Release'">$(UniversalTestCustomMacros)AppxPackageVCLibsDependency=$(AppxPackageTestDir)Dependencies\$(PlatformTarget)\Microsoft.VCLibs.$(PlatformTarget).14.00.appx;</UniversalTestCustomMacros>
|
||||||
<UniversalTestCustomMacros>$(UniversalTestCustomMacros)AppxPackageWinUIDependency=$(AppxPackageTestDir)Dependencies\$(PlatformTarget)\Microsoft.UI.Xaml.2.0.appx;</UniversalTestCustomMacros>
|
<UniversalTestCustomMacros>$(UniversalTestCustomMacros)AppxPackageWinUIDependency=$(AppxPackageTestDir)Dependencies\$(PlatformTarget)\Microsoft.UI.Xaml.2.1.appx;</UniversalTestCustomMacros>
|
||||||
<UniversalTestCustomMacros>$(UniversalTestCustomMacros)AppxPackagePublicKeyFile=@(AppxPackagePublicKeyFile->'%(FullPath)');AppxBundleOutput=@(AppxBundleOutput->'%(FullPath)');</UniversalTestCustomMacros>
|
<UniversalTestCustomMacros>$(UniversalTestCustomMacros)AppxPackagePublicKeyFile=@(AppxPackagePublicKeyFile->'%(FullPath)');AppxBundleOutput=@(AppxBundleOutput->'%(FullPath)');</UniversalTestCustomMacros>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
|
@ -26,22 +26,20 @@ bool DateCalculationEngine::AddDuration(_In_ DateTime startDate, _In_ const Date
|
||||||
{
|
{
|
||||||
m_calendar->SetDateTime(startDate);
|
m_calendar->SetDateTime(startDate);
|
||||||
|
|
||||||
|
// The Japanese Era system can have multiple year partitions within the same year.
|
||||||
|
// For example, April 30, 2019 is denoted April 30, Heisei 31; May 1, 2019 is denoted as May 1, Reiwa 1.
|
||||||
|
// The Calendar treats Heisei 31 and Reiwa 1 as separate years, which results in some unexpected behaviors where subtracting a year from Reiwa 1 results
|
||||||
|
// in a date in Heisei 31. To provide the expected result across era boundaries, we first convert the Japanese era system to a Gregorian system, do date
|
||||||
|
// math, and then convert back to the Japanese era system. This works because the Japanese era system maintains the same year/month boundaries and
|
||||||
|
// durations as the Gregorian system and is only different in display value.
|
||||||
|
if (currentCalendarSystem == CalendarIdentifiers::Japanese)
|
||||||
|
{
|
||||||
|
m_calendar->ChangeCalendarSystem(CalendarIdentifiers::Gregorian);
|
||||||
|
}
|
||||||
|
|
||||||
if (duration.year != 0)
|
if (duration.year != 0)
|
||||||
{
|
{
|
||||||
// The Japanese Era system can have multiple year partitions within the same year.
|
|
||||||
// For example, April 30, 2019 is denoted April 30, Heisei 31; May 1, 2019 is denoted as May 1, Reiwa 1.
|
|
||||||
// The Calendar treats Heisei 31 and Reiwa 1 as separate years, which results in some unexpected behaviors where subtracting a year from Reiwa 1
|
|
||||||
// results in a date in Heisei 31. To provide the expected result across era boundaries, we first convert the Japanese era system to a Gregorian
|
|
||||||
// system, do date math, and then convert back to the Japanese era system. This works because the Japanese era system maintains the same year/month
|
|
||||||
// boundaries and durations as the Gregorian system and is only different in display value.
|
|
||||||
if (currentCalendarSystem == CalendarIdentifiers::Japanese)
|
|
||||||
{
|
|
||||||
m_calendar->ChangeCalendarSystem(CalendarIdentifiers::Gregorian);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_calendar->AddYears(duration.year);
|
m_calendar->AddYears(duration.year);
|
||||||
|
|
||||||
m_calendar->ChangeCalendarSystem(currentCalendarSystem);
|
|
||||||
}
|
}
|
||||||
if (duration.month != 0)
|
if (duration.month != 0)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +61,8 @@ bool DateCalculationEngine::AddDuration(_In_ DateTime startDate, _In_ const Date
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_calendar->ChangeCalendarSystem(currentCalendarSystem);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,17 @@ bool DateCalculationEngine::SubtractDuration(_In_ DateTime startDate, _In_ const
|
||||||
{
|
{
|
||||||
m_calendar->SetDateTime(startDate);
|
m_calendar->SetDateTime(startDate);
|
||||||
|
|
||||||
|
// The Japanese Era system can have multiple year partitions within the same year.
|
||||||
|
// For example, April 30, 2019 is denoted April 30, Heisei 31; May 1, 2019 is denoted as May 1, Reiwa 1.
|
||||||
|
// The Calendar treats Heisei 31 and Reiwa 1 as separate years, which results in some unexpected behaviors where subtracting a year from Reiwa 1 results
|
||||||
|
// in a date in Heisei 31. To provide the expected result across era boundaries, we first convert the Japanese era system to a Gregorian system, do date
|
||||||
|
// math, and then convert back to the Japanese era system. This works because the Japanese era system maintains the same year/month boundaries and
|
||||||
|
// durations as the Gregorian system and is only different in display value.
|
||||||
|
if (currentCalendarSystem == CalendarIdentifiers::Japanese)
|
||||||
|
{
|
||||||
|
m_calendar->ChangeCalendarSystem(CalendarIdentifiers::Gregorian);
|
||||||
|
}
|
||||||
|
|
||||||
if (duration.day != 0)
|
if (duration.day != 0)
|
||||||
{
|
{
|
||||||
m_calendar->AddDays(-duration.day);
|
m_calendar->AddDays(-duration.day);
|
||||||
|
@ -88,22 +99,8 @@ bool DateCalculationEngine::SubtractDuration(_In_ DateTime startDate, _In_ const
|
||||||
}
|
}
|
||||||
if (duration.year != 0)
|
if (duration.year != 0)
|
||||||
{
|
{
|
||||||
// The Japanese Era system can have multiple year partitions within the same year.
|
|
||||||
// For example, April 30, 2019 is denoted April 30, Heisei 31; May 1, 2019 is denoted as May 1, Reiwa 1.
|
|
||||||
// The Calendar treats Heisei 31 and Reiwa 1 as separate years, which results in some unexpected behaviors where subtracting a year from Reiwa 1
|
|
||||||
// results in a date in Heisei 31. To provide the expected result across era boundaries, we first convert the Japanese era system to a Gregorian
|
|
||||||
// system, do date math, and then convert back to the Japanese era system. This works because the Japanese era system maintains the same year/month
|
|
||||||
// boundaries and durations as the Gregorian system and is only different in display value.
|
|
||||||
if (currentCalendarSystem == CalendarIdentifiers::Japanese)
|
|
||||||
{
|
|
||||||
m_calendar->ChangeCalendarSystem(CalendarIdentifiers::Gregorian);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_calendar->AddYears(-duration.year);
|
m_calendar->AddYears(-duration.year);
|
||||||
|
|
||||||
m_calendar->ChangeCalendarSystem(currentCalendarSystem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*endDate = m_calendar->GetDateTime();
|
*endDate = m_calendar->GetDateTime();
|
||||||
}
|
}
|
||||||
catch (Platform::InvalidArgumentException ^ ex)
|
catch (Platform::InvalidArgumentException ^ ex)
|
||||||
|
@ -115,6 +112,8 @@ bool DateCalculationEngine::SubtractDuration(_In_ DateTime startDate, _In_ const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_calendar->ChangeCalendarSystem(currentCalendarSystem);
|
||||||
|
|
||||||
// Check that the UniversalTime value is not negative
|
// Check that the UniversalTime value is not negative
|
||||||
return (endDate->UniversalTime >= 0);
|
return (endDate->UniversalTime >= 0);
|
||||||
}
|
}
|
||||||
|
@ -310,24 +309,23 @@ DateTime DateCalculationEngine::AdjustCalendarDate(Windows::Foundation::DateTime
|
||||||
{
|
{
|
||||||
m_calendar->SetDateTime(date);
|
m_calendar->SetDateTime(date);
|
||||||
|
|
||||||
|
// The Japanese Era system can have multiple year partitions within the same year.
|
||||||
|
// For example, April 30, 2019 is denoted April 30, Heisei 31; May 1, 2019 is denoted as May 1, Reiwa 1.
|
||||||
|
// The Calendar treats Heisei 31 and Reiwa 1 as separate years, which results in some unexpected behaviors where subtracting a year from Reiwa 1 results in
|
||||||
|
// a date in Heisei 31. To provide the expected result across era boundaries, we first convert the Japanese era system to a Gregorian system, do date math,
|
||||||
|
// and then convert back to the Japanese era system. This works because the Japanese era system maintains the same year/month boundaries and durations as
|
||||||
|
// the Gregorian system and is only different in display value.
|
||||||
|
auto currentCalendarSystem = m_calendar->GetCalendarSystem();
|
||||||
|
if (currentCalendarSystem == CalendarIdentifiers::Japanese)
|
||||||
|
{
|
||||||
|
m_calendar->ChangeCalendarSystem(CalendarIdentifiers::Gregorian);
|
||||||
|
}
|
||||||
|
|
||||||
switch (dateUnit)
|
switch (dateUnit)
|
||||||
{
|
{
|
||||||
case DateUnit::Year:
|
case DateUnit::Year:
|
||||||
{
|
|
||||||
// In the Japanese calendar, transition years have 2 partial years.
|
|
||||||
// It is not guaranteed that adding 1 year will always add 365 days in the Japanese Calendar.
|
|
||||||
// To work around this quirk, we will change the calendar system to Gregorian before adding 1 year in the Japanese Calendar case only.
|
|
||||||
// We will then return the calendar system back to the Japanese Calendar.
|
|
||||||
auto currentCalendarSystem = m_calendar->GetCalendarSystem();
|
|
||||||
if (currentCalendarSystem == CalendarIdentifiers::Japanese)
|
|
||||||
{
|
|
||||||
m_calendar->ChangeCalendarSystem(CalendarIdentifiers::Gregorian);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_calendar->AddYears(difference);
|
m_calendar->AddYears(difference);
|
||||||
m_calendar->ChangeCalendarSystem(currentCalendarSystem);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DateUnit::Month:
|
case DateUnit::Month:
|
||||||
m_calendar->AddMonths(difference);
|
m_calendar->AddMonths(difference);
|
||||||
break;
|
break;
|
||||||
|
@ -336,5 +334,7 @@ DateTime DateCalculationEngine::AdjustCalendarDate(Windows::Foundation::DateTime
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_calendar->ChangeCalendarSystem(currentCalendarSystem);
|
||||||
|
|
||||||
return m_calendar->GetDateTime();
|
return m_calendar->GetDateTime();
|
||||||
}
|
}
|
||||||
|
|
|
@ -839,7 +839,7 @@
|
||||||
</Target>
|
</Target>
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
<Import Project="..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets" Condition="Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets')" />
|
<Import Project="..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets" Condition="Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets')" />
|
||||||
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.0.181018004\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.0.181018004\build\native\Microsoft.UI.Xaml.targets')" />
|
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.1.190405004.2\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.1.190405004.2\build\native\Microsoft.UI.Xaml.targets')" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
@ -847,6 +847,6 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.props'))" />
|
<Error Condition="!Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.props'))" />
|
||||||
<Error Condition="!Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets'))" />
|
<Error Condition="!Exists('..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.WindowsCalculator.PGO.1.0.2\build\native\Microsoft.WindowsCalculator.PGO.targets'))" />
|
||||||
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.0.181018004\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.0.181018004\build\native\Microsoft.UI.Xaml.targets'))" />
|
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.1.190405004.2\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.1.190405004.2\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Microsoft.UI.Xaml" version="2.0.181018004" targetFramework="native" />
|
<package id="Microsoft.UI.Xaml" version="2.1.190405004.2" targetFramework="native" />
|
||||||
<package id="Microsoft.WindowsCalculator.PGO" version="1.0.2" targetFramework="native" />
|
<package id="Microsoft.WindowsCalculator.PGO" version="1.0.2" targetFramework="native" />
|
||||||
</packages>
|
</packages>
|
|
@ -958,7 +958,7 @@ TEST_METHOD(JaEraTransitionAddition)
|
||||||
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
||||||
auto cal = ref new Calendar();
|
auto cal = ref new Calendar();
|
||||||
|
|
||||||
// Showa period ended in Jan 1989.
|
// The Showa period ended in Jan 1989.
|
||||||
cal->Year = 1989;
|
cal->Year = 1989;
|
||||||
cal->Month = 1;
|
cal->Month = 1;
|
||||||
cal->Day = 1;
|
cal->Day = 1;
|
||||||
|
@ -969,14 +969,28 @@ TEST_METHOD(JaEraTransitionAddition)
|
||||||
cal->Day = 1;
|
cal->Day = 1;
|
||||||
|
|
||||||
// Expect that adding a year across boundaries adds the equivalent in the Gregorian calendar.
|
// Expect that adding a year across boundaries adds the equivalent in the Gregorian calendar.
|
||||||
auto expectedResult = cal->GetDateTime();
|
auto expectedYearResult = cal->GetDateTime();
|
||||||
DateDifference duration;
|
DateDifference yearDuration;
|
||||||
duration.year = 1;
|
yearDuration.year = 1;
|
||||||
|
|
||||||
DateTime actualResult;
|
DateTime actualYearResult;
|
||||||
viewModel->AddDuration(startTime, duration, &actualResult);
|
viewModel->AddDuration(startTime, yearDuration, &actualYearResult);
|
||||||
|
|
||||||
VERIFY_ARE_EQUAL(expectedResult.UniversalTime, actualResult.UniversalTime);
|
VERIFY_ARE_EQUAL(expectedYearResult.UniversalTime, actualYearResult.UniversalTime);
|
||||||
|
|
||||||
|
cal->Year = 1989;
|
||||||
|
cal->Month = 2;
|
||||||
|
cal->Day = 1;
|
||||||
|
|
||||||
|
// Expect that adding a month across boundaries adds the equivalent in the Gregorian calendar.
|
||||||
|
auto expectedMonthResult = cal->GetDateTime();
|
||||||
|
DateDifference monthDuration;
|
||||||
|
monthDuration.month = 1;
|
||||||
|
|
||||||
|
DateTime actualMonthResult;
|
||||||
|
viewModel->AddDuration(startTime, monthDuration, &actualMonthResult);
|
||||||
|
|
||||||
|
VERIFY_ARE_EQUAL(expectedMonthResult.UniversalTime, actualMonthResult.UniversalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(JaEraTransitionSubtraction)
|
TEST_METHOD(JaEraTransitionSubtraction)
|
||||||
|
@ -984,25 +998,61 @@ TEST_METHOD(JaEraTransitionSubtraction)
|
||||||
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
||||||
auto cal = ref new Calendar();
|
auto cal = ref new Calendar();
|
||||||
|
|
||||||
// Showa period ended in Jan 1989.
|
// The Showa period ended in Jan 1989.
|
||||||
cal->Year = 1990;
|
cal->Year = 1989;
|
||||||
|
cal->Month = 2;
|
||||||
|
cal->Day = 1;
|
||||||
|
auto startTime = cal->GetDateTime();
|
||||||
|
|
||||||
|
cal->Year = 1988;
|
||||||
|
cal->Month = 2;
|
||||||
|
cal->Day = 1;
|
||||||
|
|
||||||
|
// Expect that adding a year across boundaries adds the equivalent in the Gregorian calendar.
|
||||||
|
auto expectedYearResult = cal->GetDateTime();
|
||||||
|
DateDifference yearDuration;
|
||||||
|
yearDuration.year = 1;
|
||||||
|
|
||||||
|
DateTime actualYearResult;
|
||||||
|
viewModel->SubtractDuration(startTime, yearDuration, &actualYearResult);
|
||||||
|
|
||||||
|
VERIFY_ARE_EQUAL(expectedYearResult.UniversalTime, actualYearResult.UniversalTime);
|
||||||
|
|
||||||
|
cal->Year = 1989;
|
||||||
|
cal->Month = 1;
|
||||||
|
cal->Day = 1;
|
||||||
|
|
||||||
|
// Expect that adding a month across boundaries adds the equivalent in the Gregorian calendar.
|
||||||
|
auto expectedMonthResult = cal->GetDateTime();
|
||||||
|
DateDifference monthDuration;
|
||||||
|
monthDuration.month = 1;
|
||||||
|
|
||||||
|
DateTime actualMonthResult;
|
||||||
|
viewModel->SubtractDuration(startTime, monthDuration, &actualMonthResult);
|
||||||
|
|
||||||
|
VERIFY_ARE_EQUAL(expectedMonthResult.UniversalTime, actualMonthResult.UniversalTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(JaEraTransitionDifference)
|
||||||
|
{
|
||||||
|
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
||||||
|
auto cal = ref new Calendar();
|
||||||
|
|
||||||
|
// The Showa period ended in Jan 8, 1989. Pick 2 days across that boundary
|
||||||
|
cal->Year = 1989;
|
||||||
cal->Month = 1;
|
cal->Month = 1;
|
||||||
cal->Day = 1;
|
cal->Day = 1;
|
||||||
auto startTime = cal->GetDateTime();
|
auto startTime = cal->GetDateTime();
|
||||||
|
|
||||||
cal->Year = 1989;
|
cal->Year = 1989;
|
||||||
cal->Month = 1;
|
cal->Month = 1;
|
||||||
cal->Day = 1;
|
cal->Day = 20;
|
||||||
|
auto endTime = cal->GetDateTime();
|
||||||
|
|
||||||
// Expect that adding a year across boundaries adds the equivalent in the Gregorian calendar.
|
DateDifference diff;
|
||||||
auto expectedResult = cal->GetDateTime();
|
viewModel->GetDateDifference(startTime, endTime, DateUnit::Day, &diff);
|
||||||
DateDifference duration;
|
|
||||||
duration.year = 1;
|
|
||||||
|
|
||||||
DateTime actualResult;
|
VERIFY_ARE_EQUAL(diff.day, 19);
|
||||||
viewModel->SubtractDuration(startTime, duration, &actualResult);
|
|
||||||
|
|
||||||
VERIFY_ARE_EQUAL(expectedResult.UniversalTime, actualResult.UniversalTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue