/
usr
/
include
/
boost
/
date_time
/
/usr/include/boost/date_time
mkdir
upload
Name
Size
Mode
Actions
gregorian/
-
0755
rm
local_time/
-
0755
rm
posix_time/
-
0755
rm
adjust_functors.hpp
5467
0644
edit
dl
rm
compiler_config.hpp
5640
0644
edit
dl
rm
constrained_value.hpp
4224
0644
edit
dl
rm
c_local_time_adjustor.hpp
2631
0644
edit
dl
rm
c_time.hpp
4496
0644
edit
dl
rm
date.hpp
7357
0644
edit
dl
rm
date_clock_device.hpp
2299
0644
edit
dl
rm
date_defs.hpp
701
0644
edit
dl
rm
date_duration.hpp
4669
0644
edit
dl
rm
date_duration_types.hpp
9186
0644
edit
dl
rm
date_facet.hpp
29314
0644
edit
dl
rm
date_formatting.hpp
4208
0644
edit
dl
rm
date_formatting_limited.hpp
3461
0644
edit
dl
rm
date_formatting_locales.hpp
6748
0644
edit
dl
rm
date_format_simple.hpp
3128
0644
edit
dl
rm
date_generators.hpp
16508
0644
edit
dl
rm
date_generator_formatter.hpp
11715
0644
edit
dl
rm
date_generator_parser.hpp
13064
0644
edit
dl
rm
date_iterator.hpp
3305
0644
edit
dl
rm
date_names_put.hpp
10754
0644
edit
dl
rm
date_parsing.hpp
14146
0644
edit
dl
rm
dst_rules.hpp
15401
0644
edit
dl
rm
dst_transition_generators.hpp
2293
0644
edit
dl
rm
filetime_functions.hpp
3163
0644
edit
dl
rm
find_match.hpp
1355
0644
edit
dl
rm
format_date_parser.hpp
23909
0644
edit
dl
rm
gregorian_calendar.hpp
2714
0644
edit
dl
rm
gregorian_calendar.ipp
7947
0644
edit
dl
rm
int_adapter.hpp
14463
0644
edit
dl
rm
iso_format.hpp
5640
0644
edit
dl
rm
locale_config.hpp
1206
0644
edit
dl
rm
local_timezone_defs.hpp
7618
0644
edit
dl
rm
local_time_adjustor.hpp
8578
0644
edit
dl
rm
microsec_time_clock.hpp
6257
0644
edit
dl
rm
parse_format_base.hpp
961
0644
edit
dl
rm
period.hpp
11936
0644
edit
dl
rm
period_formatter.hpp
7237
0644
edit
dl
rm
period_parser.hpp
7932
0644
edit
dl
rm
special_defs.hpp
633
0644
edit
dl
rm
special_values_formatter.hpp
3657
0644
edit
dl
rm
special_values_parser.hpp
6161
0644
edit
dl
rm
strings_from_facet.hpp
4505
0644
edit
dl
rm
string_convert.hpp
1002
0644
edit
dl
rm
string_parse_tree.hpp
8405
0644
edit
dl
rm
time.hpp
6788
0644
edit
dl
rm
time_clock.hpp
2245
0644
edit
dl
rm
time_defs.hpp
942
0644
edit
dl
rm
time_duration.hpp
10569
0644
edit
dl
rm
time_facet.hpp
58988
0644
edit
dl
rm
time_formatting_streams.hpp
3752
0644
edit
dl
rm
time_iterator.hpp
1438
0644
edit
dl
rm
time_parsing.hpp
11846
0644
edit
dl
rm
time_resolution_traits.hpp
6760
0644
edit
dl
rm
time_system_counted.hpp
9051
0644
edit
dl
rm
time_system_split.hpp
8077
0644
edit
dl
rm
time_zone_base.hpp
3711
0644
edit
dl
rm
time_zone_names.hpp
3103
0644
edit
dl
rm
tz_db_base.hpp
15915
0644
edit
dl
rm
wrapping_int.hpp
5824
0644
edit
dl
rm
year_month_day.hpp
1375
0644
edit
dl
rm
Edit:
/usr/include/boost/date_time/gregorian_calendar.ipp
(7947B)
/* Copyright (c) 2002,2003 CrystalClear Software, Inc. * Use, modification and distribution is subject to the * Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) * Author: Jeff Garland, Bart Garst * $Date$ */ namespace boost { namespace date_time { //! Return the day of the week (0==Sunday, 1==Monday, etc) /*! Converts a year-month-day into a day of the week number */ template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline unsigned short gregorian_calendar_base<ymd_type_,date_int_type_>::day_of_week(const ymd_type& ymd) { unsigned short a = static_cast<unsigned short>((14-ymd.month)/12); unsigned short y = static_cast<unsigned short>(ymd.year - a); unsigned short m = static_cast<unsigned short>(ymd.month + 12*a - 2); unsigned short d = static_cast<unsigned short>((ymd.day + y + (y/4) - (y/100) + (y/400) + (31*m)/12) % 7); //std::cout << year << "-" << month << "-" << day << " is day: " << d << "\n"; return d; } //!Return the iso week number for the date /*!Implements the rules associated with the iso 8601 week number. Basically the rule is that Week 1 of the year is the week that contains January 4th or the week that contains the first Thursday in January. Reference for this algorithm is the Calendar FAQ by Claus Tondering, April 2000. */ template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline int gregorian_calendar_base<ymd_type_,date_int_type_>::week_number(const ymd_type& ymd) { unsigned long julianbegin = julian_day_number(ymd_type(ymd.year,1,1)); unsigned long juliantoday = julian_day_number(ymd); unsigned long day = (julianbegin + 3) % 7; unsigned long week = (juliantoday + day - julianbegin + 4)/7; if ((week >= 1) && (week <= 52)) { return static_cast<int>(week); } if (week == 53) { if((day==6) ||(day == 5 && is_leap_year(ymd.year))) { return static_cast<int>(week); //under these circumstances week == 53. } else { return 1; //monday - wednesday is in week 1 of next year } } //if the week is not in current year recalculate using the previous year as the beginning year else if (week == 0) { julianbegin = julian_day_number(ymd_type(static_cast<unsigned short>(ymd.year-1),1,1)); juliantoday = julian_day_number(ymd); day = (julianbegin + 3) % 7; week = (juliantoday + day - julianbegin + 4)/7; return static_cast<int>(week); } return static_cast<int>(week); //not reachable -- well except if day == 5 and is_leap_year != true } //! Convert a ymd_type into a day number /*! The day number is an absolute number of days since the start of count */ template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline date_int_type_ gregorian_calendar_base<ymd_type_,date_int_type_>::day_number(const ymd_type& ymd) { unsigned short a = static_cast<unsigned short>((14-ymd.month)/12); unsigned short y = static_cast<unsigned short>(ymd.year + 4800 - a); unsigned short m = static_cast<unsigned short>(ymd.month + 12*a - 3); unsigned long d = ymd.day + ((153*m + 2)/5) + 365*y + (y/4) - (y/100) + (y/400) - 32045; return static_cast<date_int_type>(d); } //! Convert a year-month-day into the julian day number /*! Since this implementation uses julian day internally, this is the same as the day_number. */ template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline date_int_type_ gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd) { return day_number(ymd); } //! Convert year-month-day into a modified julian day number /*! The day number is an absolute number of days. * MJD 0 thus started on 17 Nov 1858(Gregorian) at 00:00:00 UTC */ template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline date_int_type_ gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd) { return julian_day_number(ymd)-2400001; //prerounded } //! Change a day number into a year-month-day template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline ymd_type_ gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber) { date_int_type a = dayNumber + 32044; date_int_type b = (4*a + 3)/146097; date_int_type c = a-((146097*b)/4); date_int_type d = (4*c + 3)/1461; date_int_type e = c - (1461*d)/4; date_int_type m = (5*e + 2)/153; unsigned short day = static_cast<unsigned short>(e - ((153*m + 2)/5) + 1); unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10)); year_type year = static_cast<unsigned short>(100*b + d - 4800 + (m/10)); //std::cout << year << "-" << month << "-" << day << "\n"; return ymd_type(static_cast<unsigned short>(year),month,day); } //! Change a day number into a year-month-day template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline ymd_type_ gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber) { date_int_type a = dayNumber + 32044; date_int_type b = (4*a+3)/146097; date_int_type c = a - ((146097*b)/4); date_int_type d = (4*c + 3)/1461; date_int_type e = c - ((1461*d)/4); date_int_type m = (5*e + 2)/153; unsigned short day = static_cast<unsigned short>(e - ((153*m + 2)/5) + 1); unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10)); year_type year = static_cast<year_type>(100*b + d - 4800 + (m/10)); //std::cout << year << "-" << month << "-" << day << "\n"; return ymd_type(year,month,day); } //! Change a modified julian day number into a year-month-day template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline ymd_type_ gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(date_int_type dayNumber) { date_int_type jd = dayNumber + 2400001; //is 2400000.5 prerounded return from_julian_day_number(jd); } //! Determine if the provided year is a leap year /*! *@return true if year is a leap year, false otherwise */ template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline bool gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year) { //divisible by 4, not if divisible by 100, but true if divisible by 400 return (!(year % 4)) && ((year % 100) || (!(year % 400))); } //! Calculate the last day of the month /*! Find the day which is the end of the month given year and month * No error checking is performed. */ template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline unsigned short gregorian_calendar_base<ymd_type_,date_int_type_>::end_of_month_day(year_type year, month_type month) { switch (month) { case 2: if (is_leap_year(year)) { return 29; } else { return 28; } case 4: case 6: case 9: case 11: return 30; default: return 31; } } //! Provide the ymd_type specification for the calendar start template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline ymd_type_ gregorian_calendar_base<ymd_type_,date_int_type_>::epoch() { return ymd_type(1400,1,1); } //! Defines length of a week for week calculations template<typename ymd_type_, typename date_int_type_> BOOST_CXX14_CONSTEXPR inline unsigned short gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week() { return 7; } } } //namespace gregorian
Save
cmd:
run