PrevUpHomeNext

Reference

Header <fd/algorithm.h>
Header <fd/date_time.h>
Header <fd/date_time_typed.h>
Header <fd/functional.h>
Header <fd/interval_schedule_definition.h>
Header <fd/interval_types.h>
Header <fd/ptime_iteration.h>
Header <fd/ptime_iteration_visitors.h>
Header <fd/ptree_io.h>
Header <fd/ptree_io_xml.h>
Header <fd/schedule_timepiece.h>
Header <fd/synkronize_version.h>

Header <fd/algorithm.h>

namespace fd {

  // Check whether 'now' is within onset+ending timepoints. 
  template<typename TP> 
    bool within_interval(const TP & now, const std::pair< TP, TP > & interval);
  template<typename TP> 
    bool within_boundary(const TP &, const std::pair< TP, TP > &);

  // Check whether 'now' isn't beyond schedule's activity boundary and schedule hasn't completed yet. 
  template<auto conv, typename TP> 
    bool within_activity_boundary(const TP & now, 
                                  const schedule_timepiece & s);
  template<std::ranges::input_range Rng, typename Proj = std::identity> 
    bool all_schedules_completed(const Rng &, Proj && = {});
  template<std::ranges::input_range Rng, typename Proj = std::identity> 
    bool any_of_fixed_duration(const Rng &, Proj && = {});
  template<std::ranges::input_range Rng, typename Proj = std::identity> 
    bool none_of_fixed_duration(const Rng &, Proj && = {});
  template<std::ranges::input_range Rng, typename Proj = std::identity> 
    bool execution_scheduled(const Rng &, scheduling_purpose, Proj && = {});
  template<std::ranges::input_range Rng> 
    bool schedule_implicitly_down(const Rng &, scheduling_purpose);
  template<auto conv, typename TP, std::ranges::forward_range Rng> 
    std::optional< bool > within_schedule_uptime(const TP &, const Rng &);
  template<std::ranges::forward_range Rng> 
    std::optional< std::pair< schedule_timepoint, schedule_timepoint > > 
    uptime_bounds_for(const schedule_timepoint &, const Rng &);
  template<std::ranges::forward_range Rng> 
    std::optional< std::pair< schedule_timepoint, schedule_timepoint > > 
    uptime_bounds_for_action(const schedule_timepiece &, const Rng &);
  bool within_activity_boundary(const schedule_timepoint & now, 
                                const schedule_timepiece & schedule);
  template<std::ranges::forward_range Rng> 
    std::optional< bool > 
    within_schedule_uptime(const schedule_timepoint & now, 
                           const Rng & schedules);
  template<std::ranges::forward_range Rng> 
    std::optional< bool > 
    within_schedule_uptime(time_t now, const Rng & schedules);
  template<std::ranges::forward_range Rng> 
    std::optional< bool > 
    within_schedule_uptime(std::chrono::system_clock::time_point now, 
                           const Rng & schedules);
}

Header <fd/date_time.h>

namespace fd {
  enum iso_weekday_value;
  iso_weekday_value iso_first_dow_from(iso_weekday_value);
  constexpr int convert_weekday(int, int, int);
  constexpr int convert_weekday(int, iso_weekday_value, iso_weekday_value);

  // Calculate offset from a weekday to the following. 
  constexpr int 
  offset_to_following_weekday(int fromWeekday, int toFollowingWeekday);

  // Calculate negative offset from a weekday to the previous. 
  constexpr int offset_to_prev_weekday(int fromWeekday, int toPrevWeekday);
}
namespace fd {
  struct to_iso_weekday_value;

  // Enumeration of ISO 8601 weekday names. 
  enum iso_weekday { mon, tue, wed, thu, fri, sat, sun, first = = mon, 
                     second = = tue, third = = wed, fourth = = thu, 
                     fifth = = fri, sixth = = sat, seventh = = sun, 
                     last = = sun, first_dow = = first };

  // Enumeration of special designators for locale-based calculations to iso_weekday. 
  enum special_iso_weekday { first_dow_from_system_locale = = -1, 
                             first_dow_from_user_locale = = -2 };

  typedef std::variant< iso_weekday, special_iso_weekday > iso_weekday_variant;  // Variant holding a iso-based weekday. 
  constexpr iso_weekday iso_first_dow_from(iso_weekday);
  iso_weekday iso_first_dow_from(special_iso_weekday);
  constexpr int convert_weekday(int, iso_weekday, iso_weekday);
}

Header <fd/functional.h>

namespace fd {
  enum scheduling_purpose;

  typedef schedule_time_system::time_duration_type::traits_type schedule_time_traits;
  typedef std::chrono::duration< schedule_time_traits::tick_type, std::ratio< 1, schedule_time_traits::ticks_per_second > > schedule_duration;

  static constexpr decltype(schedule_timepoint_to_ts) & ts_from_schedule_tp;
  static constexpr decltype(schedule_timepoint_to_s) & s_from_schedule_tp;
  static constexpr decltype(schedule_timepoint_to_tp) & tp_from_schedule_tp;

  // Check whether given schedule has completed. 
  bool has_completed(const schedule_timepiece & schedule);

  // Check whether given schedule has completed. 
  bool has_schedule_completed(const schedule_timepiece & schedule);

  // Check whether given schedule is an 'action' schedule, which is mutually exclusive with is_fixed_duration_schedule(). 
  bool is_action_schedule(const schedule_timepiece & schedule);

  // Check whether given schedule is an 'action' schedule used in the context of application uptime. 
  bool is_application_action_schedule(const schedule_timepiece & schedule, 
                                      scheduling_purpose purpose);

  // Check whether given schedule is an 'action' schedule used for task execution. 
  bool is_task_execution_schedule(const schedule_timepiece & schedule, 
                                  scheduling_purpose purpose);

  // Check whether given schedule is a 'fixed duration' ('uptime' or 'downtime') schedule, which is mutually exclusive with is_action_schedule(). 
  bool is_fixed_duration_schedule(const schedule_timepiece & schedule);

  // Check whether given schedule is an 'uptime' schedule, which is mutually exclusive with is_action_schedule() and is_downtime_schedule(). 
  bool is_uptime_schedule(const schedule_timepiece & schedule);

  // Check whether given schedule is a 'fixed duration' schedule, which is mutually exclusive with is_action_schedule() and is_uptime_schedule(). 
  bool is_downtime_schedule(const schedule_timepiece & schedule);

  // Check whether given schedule is a completed 'downtime' schedule. 
  bool is_completed_downtime_schedule(const schedule_timepiece & schedule);

  // Check whether given schedule is an ongoing 'action' schedule. 
  bool is_ongoing_action_schedule(const schedule_timepiece & schedule);

  // Check whether given schedule is a completed 'application action' schedule. 
  bool is_completed_application_action_schedule(const schedule_timepiece & schedule, 
                                                scheduling_purpose purpose);

  // Check whether given schedule is a completed 'task execution' schedule. 
  bool is_completed_task_execution_schedule(const schedule_timepiece & schedule, 
                                            scheduling_purpose purpose);

  // Check whether given schedule is an ongoing 'fixed duration' schedule. 
  bool is_ongoing_fixed_duration_schedule(const schedule_timepiece & schedule);
  bool is_non_operational_interval(const std::pair< schedule_timepoint, schedule_timepoint > &);
  bool is_non_operational_interval(const schedule_timepiece &);

  // Copy schedule timepoint unchanged. 
  schedule_timepoint schedule_timepoint_ident(schedule_timepoint tp);

  // Convert a unix timestamp to a schedule timepoint (in local time). 
  schedule_timepoint ts_to_schedule_timepoint(time_t ts);

  // Convert a schedule timepoint (in local time) to a unix timestamp, 0 if not a date/time. 
  time_t schedule_timepoint_to_ts(const schedule_timepoint & tp);

  // Convert seconds (UTC assumed) to a schedule timepoint (in local time). 
  schedule_timepoint s_to_schedule_timepoint(std::chrono::seconds s);

  // Convert a schedule timepoint (in local time) to seconds (in UTC), 0 if not a date/time. 
  std::chrono::seconds schedule_timepoint_to_s(const schedule_timepoint & tp);

  // Convert a system clock timepoint to a schedule timepoint (in local time). 
  schedule_timepoint 
  tp_to_schedule_timepoint(std::chrono::system_clock::time_point tp);

  // Convert a schedule timepoint (in local time) to a system clock timepoint, 0 if not a date/time. 
  std::chrono::system_clock::time_point 
  schedule_timepoint_to_tp(const schedule_timepoint & tp);

  // Currently calculated onset timepoint, converted to explicitly specified return type; 0 if past activity frame (i.e. completed). 
  template<typename R = schedule_timepoint> 
    R currently_scheduled_at(const schedule_timepiece & schedule);

  // Currently calculated onset timepoint, converted by explicitly specified conversion function; 0 if past activity frame (i.e. completed). 
  template<auto conv> 
    decltype(auto) currently_scheduled_at(const schedule_timepiece & schedule);

  // Currently calculated ending timepoint, converted to explicitly specified return type; 0 if past activity frame (i.e. completed). 
  template<typename R = schedule_timepoint> 
    R currently_ending_at(const schedule_timepiece & schedule);

  // Currently calculated ending timepoint, converted by explicitly specified conversion function; 0 if past activity frame (i.e. completed). 
  template<auto conv> 
    decltype(auto) currently_ending_at(const schedule_timepiece & schedule);

  // Currently calculated onset timepoint since unix epoch (in UTC); 0 if past activity frame (i.e. completed). 
  time_t currently_scheduled_at__ts(const schedule_timepiece & schedule);

  // Currently calculated ending timepoint since unix epoch (in UTC); 0 if past activity frame (i.e. completed). 
  time_t currently_ending_at__ts(const schedule_timepiece & schedule);

  // Currently calculated onset timepoint in seconds since unix epoch (in UTC); 0 if past activity frame (i.e. completed). 
  std::chrono::seconds 
  currently_scheduled_at__s(const schedule_timepiece & schedule);

  // Currently calculated ending timepoint in seconds since unix epoch (in UTC); 0 if past activity frame (i.e. completed). 
  std::chrono::seconds 
  currently_ending_at__s(const schedule_timepiece & schedule);

  // Currently calculated onset timepoint as a system clock timepoint; 0 if past activity frame (i.e. completed). 
  std::chrono::system_clock::time_point 
  currently_scheduled_at__tp(const schedule_timepiece & schedule);

  // Currently calculated ending timepoint as a system clock timepoint; 0 if past activity frame (i.e. completed). 
  std::chrono::system_clock::time_point 
  currently_ending_at__tp(const schedule_timepiece & schedule);

  // Convert a pair of timepoints denoting a time span to explicitly specified return type. 
  template<typename R = schedule_timepoint> 
    std::pair< R, R > 
    convert(const std::pair< schedule_timepoint, schedule_timepoint > & span);

  // Convert a pair of timepoints denoting a time span using explicitly specified conversion function. 
  template<auto conv> 
    decltype(auto) 
    convert(const std::pair< schedule_timepoint, schedule_timepoint > & span);

  // Currently calculated onset+ending timepoints, converted to explicitly specified return type; 0 if past activity frame (i.e. completed). 
  template<typename R = schedule_timepoint> 
    std::pair< R, R > current_interval(const schedule_timepiece & schedule);

  // Currently calculated onset+ending timepoints, converted by explicitly specified conversion function; 0 if past activity frame (i.e. completed). 
  template<auto conv> 
    decltype(auto) current_interval(const schedule_timepiece & schedule);

  // Currently calculated onset+ending timepoints since unix epoch (in UTC); 0 if past activity frame (i.e. completed). 
  std::pair< time_t, time_t > 
  current_interval__ts(const schedule_timepiece & schedule);

  // Currently calculated onset+ending timepoints in seconds since unix epoch (in UTC); 0 if past activity frame (i.e. completed). 
  std::pair< std::chrono::seconds, std::chrono::seconds > 
  current_interval__s(const schedule_timepiece & schedule);

  // Currently calculated onset+ending timepoints as system clock timepoints; 0 if past activity frame (i.e. completed). 
  std::pair< std::chrono::system_clock::time_point, std::chrono::system_clock::time_point > 
  current_interval__tp(const schedule_timepiece & schedule);

  // Advance timepoint generator, then return currently scheduled onset timepoint, converted to explicitly specified return type. 
  template<typename R = schedule_timepoint> 
    R advance(schedule_timepiece & schedule, timepiece_move advanceTo, 
              const schedule_timepoint & now = schedule_clock::local_time());

  // Advance timepoint generator, then return currently scheduled onset timepoint, converted by explicitly specified conversion function. 
  template<auto conv> 
    decltype(auto) 
    advance(schedule_timepiece & schedule, timepiece_move advanceTo, 
            const schedule_timepoint & now = schedule_clock::local_time());

  // Advance timepoint generator, then return currently scheduled onset timepoint, converted to a unix timestamp (in UTC). 
  time_t advance__ts(schedule_timepiece & schedule, timepiece_move advanceTo, 
                     const schedule_timepoint & now = schedule_clock::local_time());

  // Advance timepoint generator, then return currently scheduled onset timepoint, converted to seconds (in UTC). 
  std::chrono::seconds 
  advance__s(schedule_timepiece & schedule, timepiece_move advanceTo, 
             const schedule_timepoint & now = schedule_clock::local_time());

  // Advance timepoint generator, then return currently scheduled onset timepoint, converted to a system clock timepoint. 
  std::chrono::system_clock::time_point 
  advance__tp(schedule_timepiece & schedule, timepiece_move advanceTo, 
              const schedule_timepoint & now = schedule_clock::local_time());
}
namespace fd {
  struct interval_schedule_data;

  class interval_schedule_definition;

  enum onset_series_blueprint_category { 
                                         onset_series_sub_blueprint = = INT32_MIN, 
                                         onset_series_duration_blueprint = = -(INT32_MIN >> 1) };
  enum onset_series_blueprint;
  bool is_category(onset_series_blueprint blueprint, 
                   onset_series_blueprint_category category);
}
namespace fd {
  struct interval_spec;
  struct interval_onset;
  struct interval_onset_duration;

  enum interval_granularity { invalid_interval_granularity = = 0, 
                              second_interval = = 0x01, 
                              minute_interval = = 0x02, 
                              hour_interval = = 0x04, day_interval = = 0x08, 
                              week_interval = = 0x10, month_interval = = 0x20, 
                              year_interval = = 0x40, 
                              first_interval_granularity = = second_interval, 
                              last_interval_granularity = = year_interval };

  enum special_interval_factor { numeric_interval_factor = = 0, 
                                 leapyear_interval_factor = = -1 };
  typedef int32_t time_value_t;
  typedef unsigned short greg_value_t;

  constexpr auto time_intervals;
  constexpr auto date_intervals;
  constexpr auto day_intervals;
  constexpr int convert_weekday(const interval_onset &, iso_weekday_value);
  bool operator==(const interval_onset & o2, const interval_onset & o1);
}
namespace fd {
  template<typename date_type> class leapyear_filter_functor;
  class leapyear_iterator;

  struct ptime_iteration_state;

  typedef boost::posix_time::ptime schedule_timepoint;
  typedef schedule_timepoint::time_system_type schedule_time_system;
  typedef boost::date_time::second_clock< schedule_timepoint > schedule_clock;
  typedef boost::date_time::time_itr< schedule_timepoint > schedule_time_iterator;
  typedef std::pair< DateIterator, const boost::posix_time::time_duration > date_iteration_state;
  typedef std::tuple< DateIterator, const boost::posix_time::time_duration, const boost::gregorian::nth_kday_of_month::week_num, const greg_value_t > kdate_iteration_state;
  typedef schedule_time_iterator time_iteration_state;
  typedef date_iteration_state< boost::gregorian::day_iterator > day_iteration_state;
  typedef date_iteration_state< boost::gregorian::week_iterator > week_iteration_state;
  typedef date_iteration_state< boost::gregorian::month_iterator > month_iteration_state;
  typedef kdate_iteration_state< boost::gregorian::month_iterator > kday_of_month_iteration_state;
  typedef date_iteration_state< boost::gregorian::year_iterator > year_iteration_state;
  typedef kdate_iteration_state< boost::gregorian::year_iterator > kday_of_year_iteration_state;
  typedef date_iteration_state< leapyear_iterator > leapyear_iteration_state;
  typedef kdate_iteration_state< leapyear_iterator > kday_of_leapyear_iteration_state;
  typedef std::variant< time_iteration_state, day_iteration_state, week_iteration_state, month_iteration_state, kday_of_month_iteration_state, year_iteration_state, leapyear_iteration_state, kday_of_year_iteration_state, kday_of_leapyear_iteration_state > onset_iteration_state;  // All possible date/time iteration states for generating onsets combined in a variant. 
  bool less_schedule_timepoint(const schedule_timepoint & left, 
                               const schedule_timepoint & right);
  bool less_equal_schedule_timepoint(const schedule_timepoint & left, 
                                     const schedule_timepoint & right);
}
namespace fd {
  struct progress_ptime_iteration;
  struct regress_ptime_iteration;
  struct yield_ptime;
  struct yield_next_ptime;

  typedef kj::functional_variant_visitor< Visitor > functional_ptime_iteration_visitor;
}

Header <fd/ptree_io.h>

namespace fd {

  enum ptree_io_storage { xml, json };

  static std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > u2u8conv;

  // Read a schedule from a (boost) property tree, encoded in utf-8. 
  std::vector< interval_schedule_definition > 
  read_interval_schedule(const boost::property_tree::ptree & rootTree, 
                         ptree_io_storage storageType, 
                         const std::function< void(const boost::property_tree::ptree &, interval_schedule_data *)> & read_appdata = {});
  void write_interval_schedule(boost::property_tree::ptree & rootTree, 
                               const std::vector< interval_schedule_definition > & schedules, 
                               ptree_io_storage storageType, 
                               const std::function< void(boost::property_tree::ptree &, const interval_schedule_data &)> & write_appdata = {}, 
                               std::initializer_list< std::pair< boost::property_tree::ptree::key_type, boost::property_tree::ptree::data_type >> ns = {});
}
namespace fd {
  std::vector< interval_schedule_definition > 
  read_xml_interval_schedule(std::istream &, 
                             const std::function< void(const boost::property_tree::ptree &, interval_schedule_data *)> & = {});
  void write_xml_interval_schedule(std::ostream &, 
                                   const std::vector< interval_schedule_definition > &, 
                                   const std::function< void(boost::property_tree::ptree &, const interval_schedule_data &)> & = {}, 
                                   std::initializer_list< std::pair< boost::property_tree::ptree::key_type, boost::property_tree::ptree::data_type >> = {});
}
namespace fd {
  struct timepiece_settings;

  class schedule_timepiece;

  // Designator describing where to move the timepoint generator's timeline cursor. 
  enum timepiece_move { rewind, to_adjacent_end, to_current, to_adjacent, 
                        to_adjacent_begin = = to_adjacent, to_next };
}
SYNKRONIZE_GITDESCRIBE
SYNKRONIZE_GITTAG
SYNKRONIZE_GITABBREVCOMMIT
SYNKRONIZE_GITVERSION
SYNKRONIZE_CURRENTYEAR

PrevUpHomeNext