Skip to content

Commit

Permalink
fill in TZSolar::tz_params_latitude() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ikluft committed Dec 27, 2023
1 parent bee982a commit de33e6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/cpp/libtzsolar/libtzsolar/libtzsolar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,29 @@ std::string TZSolar::tz_name ( int tz_num, bool use_lon_tz, short sign ) {
}

// check latitude data and initialize special case for polar regions - internal method called by tz_params()
void TZSolar::tz_params_latitude ( short longitude, bool use_lon_tz, short latitude ) {
bool TZSolar::tz_params_latitude ( short longitude, bool use_lon_tz, short latitude ) {
// special case: use East00/Lon000E (equal to UTC) within 10° latitude of poles
if ( abs( latitude ) >= limit_latitude - precision_fp ) {
// TODO
// note: for polar latitudes, this must set all fields on behalf of the constructor
lon_tz = use_lon_tz;
short_name = lon_tz ? "Lon000E" : "East00";
return true;
}

// TODO
return false;
}


// get timezone parameters (name and minutes offset) - called by constructor
void TZSolar::tz_params ( short longitude, bool use_lon_tz, boost::optional<short> opt_latitude ) {
// if latitude is provided, use UTC within 10° latitude of poles
if ( opt_latitude != boost::none ) {
this->tz_params_latitude( longitude, use_lon_tz, opt_latitude.get() );
if ( this->tz_params_latitude( longitude, use_lon_tz, opt_latitude.get() )) {
return;
}
}

// set time zone from longitude
// TODO
}

2 changes: 1 addition & 1 deletion src/cpp/libtzsolar/libtzsolar/libtzsolar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TZSolar {
static std::string tz_name ( int tz_num, bool use_lon_tz, short sign );

// get timezone parameters (name and minutes offset) - called by constructor
void tz_params_latitude ( short longitude, bool use_lon_tz, short latitude );
bool tz_params_latitude ( short longitude, bool use_lon_tz, short latitude );

// get timezone parameters (name and minutes offset) - called by constructor
void tz_params ( short longitude, bool use_lon_tz, boost::optional<short> opt_latitude );
Expand Down

0 comments on commit de33e6f

Please sign in to comment.