Skip to content

Commit

Permalink
SAM issue 289 - not yet working
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanzou committed Nov 5, 2024
1 parent 49c7b4a commit ed70db2
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/plot/plaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,30 +668,21 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() {

//We need to figure out whether we are looking at hours, days, or months, and label the graph appropriately.
wxDateTime timeKeeper(1, wxDateTime::Jan, 1971, 0, 0, 0); // works all time zones
wxDateTime timeKeeperRef(1, wxDateTime::Jan, 1971, 0, 0, 0); // works all time zones

// leap year for min and max values
// both are tracked as hours since Jan 1, 1971
int m_min_days_to_add = 0, m_max_days_to_add = 0;
int m_min_days_to_add = 0;
int m_min_num_years = m_min / 8760;
int m_max_num_years = m_max / 8760;

wxDateTime m_min_dt = timeKeeper;
for (size_t i = 0; i < m_min_num_years; i++) {
//wxDateTime dt = timeKeeper.Add() later than Feb 28
// auto ndays = timeKeeper.GetNumberOfDays(i);
if (m_min_dt.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt))
if (timeKeeperRef.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt))
m_min_days_to_add++;
// m_min_dt.Add(wxTimeSpan::Days(ndays+1));
}
// can start with m_min_days_to_add
wxDateTime m_max_dt = timeKeeper;
for (size_t i = 0; i < m_max_num_years; i++) {
//wxDateTime dt = timeKeeper.Add() later than Feb 28
auto ndays = timeKeeper.GetNumberOfDays(i);
if (m_max_dt.IsLeapYear())// && m_min_dt.IsLaterThan(dt))
m_max_days_to_add++;
m_max_dt.Add(wxTimeSpan::Days(ndays +1));
}



Expand Down Expand Up @@ -730,9 +721,12 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() {
timeKeeper2.Add(wxTimeSpan::Hour());
}

if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29))
// TODO condition needs to be if leap year and day of year > 2/28 then add a day...
if ((timeKeeper.GetDayOfYear() > (31 + 27)) && (timeKeeperRef.IsLeapYear(m_min/8760)))
// if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29))
timeKeeper.Add(wxTimeSpan::Hours(24));
if ((timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29))
// if ((timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29))
if ((timeKeeper2.GetDayOfYear() > (31 + 27)) && (timeKeeperRef.IsLeapYear(m_min / 8760)))
timeKeeper2.Add(wxTimeSpan::Hours(24));

//if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)
Expand Down Expand Up @@ -781,14 +775,14 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() {
}

do {
if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) {
auto str = timeKeeper.Format("%b %d");
m_tickList.push_back(TickData(time, str, TickData::NONE));
time += 12;
if (time < m_max)
m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight
time += 12;
}
if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29))
timeKeeper.Add(wxTimeSpan::Hours(24));
auto str = timeKeeper.Format("%b %d");
m_tickList.push_back(TickData(time, str, TickData::NONE));
time += 12;
if (time < m_max)
m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight
time += 12;
timeKeeper.Add(wxTimeSpan::Hours(24));
} while (time < m_max);
} else {
Expand Down

0 comments on commit ed70db2

Please sign in to comment.