Skip to content

Commit 2a591ad

Browse files
author
Jani Giannoudis
committed
QuarterTimeRange.GetMonths(): fixed year base month (including tests)
target frameworks: added support for .net8, .net9 and target frameworks: netstandard1.6 removed updated to version 2.1.6
1 parent 7561388 commit 2a591ad

File tree

5 files changed

+50
-25
lines changed

5 files changed

+50
-25
lines changed

TimePeriod/QuarterTimeRange.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ public string EndQuarterOfYearName
9595
public ITimePeriodCollection GetMonths()
9696
{
9797
TimePeriodCollection months = new TimePeriodCollection();
98+
YearMonth startMonth;
99+
TimeTool.AddMonth(startYear, YearBaseMonth, ((int)StartQuarter - 1) * TimeSpec.MonthsPerQuarter, out _, out startMonth);
98100
for ( int i = 0; i < quarterCount; i++ )
99101
{
100102
for ( int month = 0; month < TimeSpec.MonthsPerQuarter; month++ )
101103
{
102104
int year;
103105
YearMonth yearMonth;
104-
TimeTool.AddMonth( startYear, YearBaseMonth, ( i * TimeSpec.MonthsPerQuarter ) + month, out year, out yearMonth );
106+
TimeTool.AddMonth( startYear, startMonth, ( i * TimeSpec.MonthsPerQuarter ) + month, out year, out yearMonth );
105107
months.Add( new Month( year, yearMonth, Calendar ) );
106108
}
107109
}

TimePeriod/TimePeriod.csproj

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard1.6;net35;net40;net45;net46;net6;net7</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net35;net40;net45;net46;net6;net7;net8;net9</TargetFrameworks>
55
<AssemblyName>Itenso.TimePeriod</AssemblyName>
66
<RootNamespace>Itenso.TimePeriod</RootNamespace>
7-
<Version>2.1.5</Version>
7+
<Version>2.1.6</Version>
88
<Authors>Jani Giannoudis</Authors>
99
<Company />
1010
<PackageProjectUrl>http://www.codeproject.com/Articles/168662/Time-Period-Library-for-NET</PackageProjectUrl>
@@ -14,14 +14,14 @@
1414
<PackageReadmeFile>README.md</PackageReadmeFile>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1616
<PackageTags>C# ASP.NET Windows .NET Mobile Date Time Calendar</PackageTags>
17-
<PackageReleaseNotes>Restored target frameworks to netstandard1.6;net35;net40;net45;net46;net6;net7</PackageReleaseNotes>
17+
<PackageReleaseNotes>Added target frameworks net8, net9 and netstandard2.0. Removed support for netstandard1.6.</PackageReleaseNotes>
1818
<RepositoryUrl>https://github.com/Giannoudis/TimePeriodLibrary</RepositoryUrl>
1919
<RepositoryType>GitHub</RepositoryType>
2020
<PackageId>TimePeriodLibrary.NET</PackageId>
2121
<SignAssembly>True</SignAssembly>
2222
<AssemblyOriginatorKeyFile>TimePeriodLibrary.snk</AssemblyOriginatorKeyFile>
23-
<AssemblyVersion>2.1.5.0</AssemblyVersion>
24-
<FileVersion>2.1.5.0</FileVersion>
23+
<AssemblyVersion>2.1.6.0</AssemblyVersion>
24+
<FileVersion>2.1.6.0</FileVersion>
2525
</PropertyGroup>
2626

2727
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -36,19 +36,9 @@
3636
</PropertyGroup>
3737

3838
<ItemGroup>
39-
<Compile Remove="Properties\AssemblyInfo.cs" />
40-
<Compile Remove="Properties\AssemblyInfo.Title.Desktop.cs" />
41-
<Compile Remove="Properties\AssemblyInfo.Title.Pcl.cs" />
42-
<Compile Remove="Properties\AssemblyInfo.Title.Silverlight.cs" />
43-
<Compile Remove="Properties\AssemblyInfo.Title.WindowsPhone.cs" />
44-
<Compile Remove="Properties\VersionInfo.cs" />
4539
<Compile Remove="TimeLineMomentCollection.Desktop.cs" />
4640
</ItemGroup>
4741

48-
<ItemGroup>
49-
<Folder Include="Properties\" />
50-
</ItemGroup>
51-
5242
<ItemGroup>
5343
<None Include="..\README.md">
5444
<Pack>True</Pack>

TimePeriodTests/QuarterTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ public void CalendarYearQuarterTest()
216216
Assert.Equal(q4.End, new DateTime(currentYear + 1, TimeSpec.FirstQuarterMonthIndex, 1));
217217
} // CalendarYearQuarterTest
218218

219+
// ----------------------------------------------------------------------
220+
[Trait("Category", "Quarter")]
221+
[Fact]
222+
public void QuarterGetMonthsTest()
223+
{
224+
var currentYear = ClockProxy.Clock.Now.Year;
225+
226+
var q2 = new Quarter(currentYear, YearQuarter.Second);
227+
228+
var months = q2.GetMonths();
229+
Assert.Equal(3, months.Count);
230+
Assert.Equal(months[0].Start, new DateTime(currentYear, TimeSpec.SecondQuarterMonthIndex, 1));
231+
Assert.Equal(months[1].Start, new DateTime(currentYear, TimeSpec.SecondQuarterMonthIndex, 1).AddMonths(1));
232+
Assert.Equal(months[2].Start, new DateTime(currentYear, TimeSpec.SecondQuarterMonthIndex, 1).AddMonths(2));
233+
}
234+
219235
// ----------------------------------------------------------------------
220236
[Trait("Category", "Quarter")]
221237
[Fact]

TimePeriodTests/QuartersTest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ public void SingleQuartersTest()
4949
Assert.True(quarters.GetQuarters()[0].IsSamePeriod(new Quarter(2004, YearQuarter.Second)));
5050
} // SingleQuartersTest
5151

52+
// ----------------------------------------------------------------------
53+
[Trait("Category", "Quarters")]
54+
[Fact]
55+
public void QuartersGetMonthsTest()
56+
{
57+
var currentYear = ClockProxy.Clock.Now.Year;
58+
59+
var q2and3 = new Quarters(currentYear, YearQuarter.Second, 2);
60+
61+
var months = q2and3.GetMonths();
62+
Assert.Equal(6, months.Count);
63+
Assert.Equal(months[0].Start, new DateTime(currentYear, TimeSpec.SecondQuarterMonthIndex, 1));
64+
Assert.Equal(months[1].Start, new DateTime(currentYear, TimeSpec.SecondQuarterMonthIndex, 1).AddMonths(1));
65+
Assert.Equal(months[2].Start, new DateTime(currentYear, TimeSpec.SecondQuarterMonthIndex, 1).AddMonths(2));
66+
Assert.Equal(months[3].Start, new DateTime(currentYear, TimeSpec.ThirdQuarterMonthIndex, 1));
67+
Assert.Equal(months[4].Start, new DateTime(currentYear, TimeSpec.ThirdQuarterMonthIndex, 1).AddMonths(1));
68+
Assert.Equal(months[5].Start, new DateTime(currentYear, TimeSpec.ThirdQuarterMonthIndex, 1).AddMonths(2));
69+
}
70+
5271
// ----------------------------------------------------------------------
5372
[Trait("Category", "Quarters")]
5473
[Fact]

TimePeriodTests/TimePeriodTests.Core.csproj

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<PropertyGroup>
8-
<TargetFramework>net6</TargetFramework>
8+
<TargetFramework>net9</TargetFramework>
99
<Version>2.1.5</Version>
1010
<PackageId>Itenso.TimePeriodTests.Venki</PackageId>
1111
<RepositoryUrl>https://github.com/Giannoudis/TimePeriodLibrary</RepositoryUrl>
@@ -30,12 +30,14 @@
3030
<OutputPath>..\Pub\Core.Debug\</OutputPath>
3131
</PropertyGroup>
3232

33+
<ItemGroup>
34+
<Compile Remove="Properties\**" />
35+
<EmbeddedResource Remove="Properties\**" />
36+
<None Remove="Properties\**" />
37+
</ItemGroup>
38+
3339
<ItemGroup>
3440
<Compile Remove="Program.cs" />
35-
<Compile Remove="Properties\AssemblyInfo.cs" />
36-
<Compile Remove="Properties\AssemblyInfo.Title.Desktop.cs" />
37-
<Compile Remove="Properties\AssemblyInfo.Title.Pcl.cs" />
38-
<Compile Remove="Properties\VersionInfo.cs" />
3941
<Compile Remove="TestResultReport.cs" />
4042
</ItemGroup>
4143

@@ -49,10 +51,6 @@
4951
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" />
5052
</ItemGroup>
5153

52-
<ItemGroup>
53-
<Folder Include="Properties\" />
54-
</ItemGroup>
55-
5654
<ItemGroup>
5755
<ProjectReference Include="..\TimePeriod\TimePeriod.csproj" />
5856
</ItemGroup>

0 commit comments

Comments
 (0)