-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c71a194
commit 17787ec
Showing
5 changed files
with
85 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#include "dtfund.hpp" | ||
|
||
constexpr dso::ymd_date dso::ydoy_date::to_ymd() const noexcept { | ||
ymd_date yd; | ||
int guess = static_cast<int>(__doy.as_underlying_type() * 0.032); | ||
int leap = __year.is_leap(); | ||
int more = ((__doy.as_underlying_type() - | ||
int leap = yr().is_leap(); | ||
int more = ((dy().as_underlying_type() - | ||
dso::core::month_day[leap][guess + 1]) > 0); | ||
/* assign */ | ||
yd.__year = __year; | ||
yd.__month = month{guess + more + 1}; | ||
yd.__dom = day_of_month(__doy.as_underlying_type() - | ||
ymd_date yd; | ||
yd.yr() = yr(); | ||
yd.mn() = month(guess + more + 1); | ||
yd.dm() = day_of_month(dy().as_underlying_type() - | ||
dso::core::month_day[leap][guess + more]); | ||
return yd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
#include "dtfund.hpp" | ||
#include <stdexcept> | ||
|
||
dso::ydoy_date dso::ymd_date::to_ydoy() const noexcept { | ||
int leap = __year.is_leap(); | ||
int md = __month.as_underlying_type() - 1; | ||
return dso::ydoy_date(__year, dso::day_of_year(core::month_day[leap][md] + | ||
__dom.as_underlying_type())); | ||
dso::ydoy_date dso::ymd_date::to_ydoy() const { | ||
if (!is_valid()) { | ||
throw std::invalid_argument( | ||
"[ERROR] Tring to compute year/day_of_year from an invalid " | ||
"year/month/day instance (traceback:" + | ||
std::string(__func__) + ")\n"); | ||
} | ||
int leap = yr().is_leap(); | ||
int md = mn().as_underlying_type() - 1; | ||
return dso::ydoy_date(yr(), dso::day_of_year(core::month_day[leap][md] + | ||
dm().as_underlying_type())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters