aboutsummaryrefslogtreecommitdiffhomepage
path: root/absl/time/internal/cctz/include/cctz/civil_time_detail.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/time/internal/cctz/include/cctz/civil_time_detail.h')
-rw-r--r--absl/time/internal/cctz/include/cctz/civil_time_detail.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/absl/time/internal/cctz/include/cctz/civil_time_detail.h b/absl/time/internal/cctz/include/cctz/civil_time_detail.h
index 3e24340..0dcb1ad 100644
--- a/absl/time/internal/cctz/include/cctz/civil_time_detail.h
+++ b/absl/time/internal/cctz/include/cctz/civil_time_detail.h
@@ -535,7 +535,8 @@ enum class weekday {
sunday,
};
-CONSTEXPR_F weekday get_weekday(const civil_day& cd) noexcept {
+template <typename T>
+CONSTEXPR_F weekday get_weekday(const civil_time<T>& ct) noexcept {
CONSTEXPR_D weekday k_weekday_by_mon_off[13] = {
weekday::monday, weekday::tuesday, weekday::wednesday,
weekday::thursday, weekday::friday, weekday::saturday,
@@ -546,9 +547,9 @@ CONSTEXPR_F weekday get_weekday(const civil_day& cd) noexcept {
CONSTEXPR_D int k_weekday_offsets[1 + 12] = {
-1, 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4,
};
- year_t wd = 2400 + (cd.year() % 400) - (cd.month() < 3);
+ year_t wd = 2400 + (ct.year() % 400) - (ct.month() < 3);
wd += wd / 4 - wd / 100 + wd / 400;
- wd += k_weekday_offsets[cd.month()] + cd.day();
+ wd += k_weekday_offsets[ct.month()] + ct.day();
return k_weekday_by_mon_off[wd % 7 + 6];
}
@@ -594,12 +595,13 @@ CONSTEXPR_F civil_day prev_weekday(civil_day cd, weekday wd) noexcept {
}
}
-CONSTEXPR_F int get_yearday(const civil_day& cd) noexcept {
+template <typename T>
+CONSTEXPR_F int get_yearday(const civil_time<T>& ct) noexcept {
CONSTEXPR_D int k_month_offsets[1 + 12] = {
-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
};
- const int feb29 = (cd.month() > 2 && impl::is_leap_year(cd.year()));
- return k_month_offsets[cd.month()] + feb29 + cd.day();
+ const int feb29 = (ct.month() > 2 && impl::is_leap_year(ct.year()));
+ return k_month_offsets[ct.month()] + feb29 + ct.day();
}
////////////////////////////////////////////////////////////////////////