diff --git a/src/plot/plaxis.cpp b/src/plot/plaxis.cpp index a1eac6e6..3c57931a 100644 --- a/src/plot/plaxis.cpp +++ b/src/plot/plaxis.cpp @@ -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)); - } @@ -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) @@ -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 {