mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: GetMonthsP
git-svn-id: svn://ultimatepp.org/upp/trunk@10503 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3e34b9f0f6
commit
453ec91af4
3 changed files with 22 additions and 1 deletions
|
|
@ -363,6 +363,11 @@ int GetMonths(Date since, Date till)
|
|||
return 12 * till.year + till.month - (12 * since.year + since.month) + (till.day >= since.day) - 1;
|
||||
}
|
||||
|
||||
int GetMonthsP(Date since, Date till)
|
||||
{
|
||||
return 12 * till.year + till.month - (12 * since.year + since.month) + (till.day > since.day);
|
||||
}
|
||||
|
||||
Date AddYears(Date date, int years) {
|
||||
date.year += years;
|
||||
date.day = min(date.day, LastDayOfMonth(date).day);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ int DayOfYear(Date d);
|
|||
|
||||
Date AddMonths(Date date, int months);
|
||||
int GetMonths(Date since, Date till);
|
||||
int GetMonthsP(Date since, Date till);
|
||||
Date AddYears(Date date, int years);
|
||||
|
||||
Date GetWeekDate(int year, int week);
|
||||
|
|
|
|||
|
|
@ -221,7 +221,8 @@ nth], [@(0.0.255) int]_[*@3 year])&]
|
|||
[s4; &]
|
||||
[s5;:GetMonths`(Date`,Date`): [@(0.0.255) int]_[* GetMonths]([_^Date^ Date]_[*@3 since],
|
||||
[_^Date^ Date]_[*@3 till])&]
|
||||
[s2;%% Number of months between two dates.&]
|
||||
[s2;%% Number of months between two dates. Only whole months are
|
||||
counted.&]
|
||||
[s2;%% Examples:&]
|
||||
[s2;%% [*C@3 ][*C GetMonths(Date(2013, 2, 5), Date(2013, 3, 4))
|
||||
`= 0]&]
|
||||
|
|
@ -233,6 +234,20 @@ nth], [@(0.0.255) int]_[*@3 year])&]
|
|||
`= 1]&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:GetMonthsP`(Upp`:`:Date`,Upp`:`:Date`): [@(0.0.255) int]_[* GetMonthsP]([_^Upp`:`:Date^ D
|
||||
ate]_[*@3 since], [_^Upp`:`:Date^ Date]_[*@3 till])&]
|
||||
[s2;%% Number of months between two dates, including partial months.&]
|
||||
[s2;%% Examples:&]
|
||||
[s2;%% [*C GetMonthsP(Date(2016, 1, 1), Date(2016, 1, 1)) `=
|
||||
0]&]
|
||||
[s2;%% [*C GetMonthsP(Date(2016, 1, 1), Date(2016, 1, 2)) `=
|
||||
1 // partial]&]
|
||||
[s2;%% [*C GetMonthsP(Date(2016, 1, 1), Date(2016, 2, 1)) `=
|
||||
1 // exact one]&]
|
||||
[s2;%% [*C GetMonthsP(Date(2016, 1, 1), Date(2016, 2, 2)) `=
|
||||
2 // partial 2nd]&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:AddYears`(Date`,int`): [_^Date^ Date]_[* AddYears]([_^Date^ Date]_[*@3 date],
|
||||
[@(0.0.255) int]_[*@3 years])&]
|
||||
[s2;%% Adds [%-*@3 years] to [%-*@3 date] and returns the result. Note
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue