meetup: iteration 1
This commit is contained in:
parent
a41e0690df
commit
0f23771e94
2 changed files with 327 additions and 13 deletions
|
|
@ -1,20 +1,266 @@
|
|||
#include "meetup.h"
|
||||
|
||||
|
||||
namespace meetup {
|
||||
|
||||
using namespace boost::gregorian;
|
||||
typedef nth_day_of_the_week_in_month nth_dow;
|
||||
|
||||
scheduler::scheduler(month_t month, year_t year)
|
||||
: year_(year)
|
||||
, month_(month)
|
||||
{}
|
||||
|
||||
scheduler::scheduler(int month, int year)
|
||||
: month_(month)
|
||||
, year_(year)
|
||||
{
|
||||
}
|
||||
|
||||
date_t scheduler::monteenth() const
|
||||
{
|
||||
return nth_dow(/*nth_dow::first*/nth_dow::second, Monday, month_).get_date(year_);
|
||||
return teenth_day(weekdays::Monday);
|
||||
}
|
||||
|
||||
date_t scheduler::tuesteenth() const
|
||||
{
|
||||
return teenth_day(weekdays::Tuesday);
|
||||
}
|
||||
|
||||
date_t scheduler::wednesteenth() const
|
||||
{
|
||||
return teenth_day(weekdays::Wednesday);
|
||||
}
|
||||
|
||||
date_t scheduler::thursteenth() const
|
||||
{
|
||||
return teenth_day(weekdays::Thursday);
|
||||
}
|
||||
|
||||
date_t scheduler::friteenth() const
|
||||
{
|
||||
return teenth_day(weekdays::Friday);
|
||||
}
|
||||
|
||||
date_t scheduler::saturteenth() const
|
||||
{
|
||||
return teenth_day(weekdays::Saturday);
|
||||
}
|
||||
|
||||
date_t scheduler::sunteenth() const
|
||||
{
|
||||
return teenth_day(weekdays::Sunday);
|
||||
}
|
||||
|
||||
date_t scheduler::first_monday() const
|
||||
{
|
||||
return first_weekday(weekdays::Monday);
|
||||
}
|
||||
|
||||
date_t scheduler::first_tuesday() const
|
||||
{
|
||||
return first_weekday(weekdays::Tuesday);
|
||||
}
|
||||
|
||||
date_t scheduler::first_wednesday() const
|
||||
{
|
||||
return first_weekday(weekdays::Wednesday);
|
||||
}
|
||||
|
||||
date_t scheduler::first_thursday() const
|
||||
{
|
||||
return first_weekday(weekdays::Thursday);
|
||||
}
|
||||
|
||||
date_t scheduler::first_friday() const
|
||||
{
|
||||
return first_weekday(weekdays::Friday);
|
||||
}
|
||||
|
||||
date_t scheduler::first_saturday() const
|
||||
{
|
||||
return first_weekday(weekdays::Saturday);
|
||||
}
|
||||
|
||||
date_t scheduler::first_sunday() const
|
||||
{
|
||||
return first_weekday(weekdays::Sunday);
|
||||
}
|
||||
|
||||
date_t scheduler::second_monday() const
|
||||
{
|
||||
return second_weekday(weekdays::Monday);
|
||||
}
|
||||
|
||||
date_t scheduler::second_tuesday() const
|
||||
{
|
||||
return second_weekday(weekdays::Tuesday);
|
||||
}
|
||||
|
||||
date_t scheduler::second_wednesday() const
|
||||
{
|
||||
return second_weekday(weekdays::Wednesday);
|
||||
}
|
||||
|
||||
date_t scheduler::second_thursday() const
|
||||
{
|
||||
return second_weekday(weekdays::Thursday);
|
||||
}
|
||||
|
||||
date_t scheduler::second_friday() const
|
||||
{
|
||||
return second_weekday(weekdays::Friday);
|
||||
}
|
||||
|
||||
date_t scheduler::second_saturday() const
|
||||
{
|
||||
return second_weekday(weekdays::Saturday);
|
||||
}
|
||||
|
||||
date_t scheduler::second_sunday() const
|
||||
{
|
||||
return second_weekday(weekdays::Sunday);
|
||||
}
|
||||
|
||||
date_t scheduler::third_monday() const
|
||||
{
|
||||
return third_weekday(weekdays::Monday);
|
||||
}
|
||||
|
||||
date_t scheduler::third_tuesday() const
|
||||
{
|
||||
return third_weekday(weekdays::Tuesday);
|
||||
}
|
||||
|
||||
date_t scheduler::third_wednesday() const
|
||||
{
|
||||
return third_weekday(weekdays::Wednesday);
|
||||
}
|
||||
|
||||
date_t scheduler::third_thursday() const
|
||||
{
|
||||
return third_weekday(weekdays::Thursday);
|
||||
}
|
||||
|
||||
date_t scheduler::third_friday() const
|
||||
{
|
||||
return third_weekday(weekdays::Friday);
|
||||
}
|
||||
|
||||
date_t scheduler::third_saturday() const
|
||||
{
|
||||
return third_weekday(weekdays::Saturday);
|
||||
}
|
||||
|
||||
date_t scheduler::third_sunday() const
|
||||
{
|
||||
return third_weekday(weekdays::Sunday);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_monday() const
|
||||
{
|
||||
return fourth_weekday(weekdays::Monday);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_tuesday() const
|
||||
{
|
||||
return fourth_weekday(weekdays::Tuesday);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_wednesday() const
|
||||
{
|
||||
return fourth_weekday(weekdays::Wednesday);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_thursday() const
|
||||
{
|
||||
return fourth_weekday(weekdays::Thursday);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_friday() const
|
||||
{
|
||||
return fourth_weekday(weekdays::Friday);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_saturday() const
|
||||
{
|
||||
return fourth_weekday(weekdays::Saturday);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_sunday() const
|
||||
{
|
||||
return fourth_weekday(weekdays::Sunday);
|
||||
}
|
||||
|
||||
date_t scheduler::last_monday() const
|
||||
{
|
||||
return last_weekday(weekdays::Monday);
|
||||
}
|
||||
|
||||
date_t scheduler::last_tuesday() const
|
||||
{
|
||||
return last_weekday(weekdays::Tuesday);
|
||||
}
|
||||
|
||||
date_t scheduler::last_wednesday() const
|
||||
{
|
||||
return last_weekday(weekdays::Wednesday);
|
||||
}
|
||||
|
||||
date_t scheduler::last_thursday() const
|
||||
{
|
||||
return last_weekday(weekdays::Thursday);
|
||||
}
|
||||
|
||||
date_t scheduler::last_friday() const
|
||||
{
|
||||
return last_weekday(weekdays::Friday);
|
||||
}
|
||||
|
||||
date_t scheduler::last_saturday() const
|
||||
{
|
||||
return last_weekday(weekdays::Saturday);
|
||||
}
|
||||
|
||||
date_t scheduler::last_sunday() const
|
||||
{
|
||||
return last_weekday(weekdays::Sunday);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
typedef boost::gregorian::first_day_of_the_week_in_month first_dow;
|
||||
typedef boost::gregorian::first_day_of_the_week_after first_dow_after;
|
||||
typedef boost::gregorian::last_day_of_the_week_in_month last_dow;
|
||||
}
|
||||
|
||||
date_t scheduler::teenth_day(weekdays day) const
|
||||
{
|
||||
return first_dow_after(day).get_date({year_, month_, 12});
|
||||
}
|
||||
|
||||
date_t scheduler::nth_weekday(nth_dow::week_num n, weekdays day) const
|
||||
{
|
||||
return nth_dow(n, day, month_).get_date(year_);
|
||||
}
|
||||
|
||||
date_t scheduler::first_weekday(weekdays day) const
|
||||
{
|
||||
return first_dow(day, month_).get_date(year_);
|
||||
}
|
||||
|
||||
date_t scheduler::last_weekday(weekdays day) const
|
||||
{
|
||||
return last_dow(day, month_).get_date(year_);
|
||||
}
|
||||
|
||||
date_t scheduler::second_weekday(weekdays day) const
|
||||
{
|
||||
return nth_weekday(nth_dow::second, day);
|
||||
}
|
||||
|
||||
date_t scheduler::third_weekday(weekdays day) const
|
||||
{
|
||||
return nth_weekday(nth_dow::third, day);
|
||||
}
|
||||
|
||||
date_t scheduler::fourth_weekday(weekdays day) const
|
||||
{
|
||||
return nth_weekday(nth_dow::fourth, day);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue