Skip to content

Commit ed70db2

Browse files
committed
SAM issue 289 - not yet working
1 parent 49c7b4a commit ed70db2

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

src/plot/plaxis.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -668,30 +668,21 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() {
668668

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

672673
// leap year for min and max values
673674
// both are tracked as hours since Jan 1, 1971
674-
int m_min_days_to_add = 0, m_max_days_to_add = 0;
675+
int m_min_days_to_add = 0;
675676
int m_min_num_years = m_min / 8760;
676677
int m_max_num_years = m_max / 8760;
677678

678-
wxDateTime m_min_dt = timeKeeper;
679679
for (size_t i = 0; i < m_min_num_years; i++) {
680680
//wxDateTime dt = timeKeeper.Add() later than Feb 28
681681
// auto ndays = timeKeeper.GetNumberOfDays(i);
682-
if (m_min_dt.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt))
682+
if (timeKeeperRef.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt))
683683
m_min_days_to_add++;
684684
// m_min_dt.Add(wxTimeSpan::Days(ndays+1));
685685
}
686-
// can start with m_min_days_to_add
687-
wxDateTime m_max_dt = timeKeeper;
688-
for (size_t i = 0; i < m_max_num_years; i++) {
689-
//wxDateTime dt = timeKeeper.Add() later than Feb 28
690-
auto ndays = timeKeeper.GetNumberOfDays(i);
691-
if (m_max_dt.IsLeapYear())// && m_min_dt.IsLaterThan(dt))
692-
m_max_days_to_add++;
693-
m_max_dt.Add(wxTimeSpan::Days(ndays +1));
694-
}
695686

696687

697688

@@ -730,9 +721,12 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() {
730721
timeKeeper2.Add(wxTimeSpan::Hour());
731722
}
732723

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

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

783777
do {
784-
if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) {
785-
auto str = timeKeeper.Format("%b %d");
786-
m_tickList.push_back(TickData(time, str, TickData::NONE));
787-
time += 12;
788-
if (time < m_max)
789-
m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight
790-
time += 12;
791-
}
778+
if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29))
779+
timeKeeper.Add(wxTimeSpan::Hours(24));
780+
auto str = timeKeeper.Format("%b %d");
781+
m_tickList.push_back(TickData(time, str, TickData::NONE));
782+
time += 12;
783+
if (time < m_max)
784+
m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight
785+
time += 12;
792786
timeKeeper.Add(wxTimeSpan::Hours(24));
793787
} while (time < m_max);
794788
} else {

0 commit comments

Comments
 (0)