Skip to content

Commit

Permalink
feat(date, time): Add objects for Date and Time
Browse files Browse the repository at this point in the history
These two objects are particularly helpful for defining EnergyPlus schedules and there may be some other places where it is helpful to have these objects coordinated with the Ladybug DateTime and AnalysisPeriod as they are here.

This commit also adds a full set of tests for DateTime, Date, and Time.  It also includes a few corrections to places where we were internally using hasattr instead of isinstance.
  • Loading branch information
chriswmackey authored and Chris Mackey committed Aug 19, 2019
1 parent 7de62c9 commit 0126e6f
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 58 deletions.
9 changes: 3 additions & 6 deletions ladybug/analysisperiod.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def from_analysis_period(cls, analysis_period=None):
"""
if not analysis_period:
return cls()
elif hasattr(analysis_period, 'isAnalysisPeriod'):
elif isinstance(analysis_period, AnalysisPeriod):
return analysis_period
elif isinstance(analysis_period, str):
try:
Expand Down Expand Up @@ -447,11 +447,8 @@ def __eq__(self, other):
if isinstance(other, self.__class__):
if (self.st_time, self.end_time, self.timestep, self.is_leap_year) == \
(other.st_time, other.end_time, other.timestep, other.is_leap_year):
return True
else:
return False
else:
return False
return True
return False

def __ne__(self, other):
return not self.__eq__(other)
Expand Down
Loading

0 comments on commit 0126e6f

Please sign in to comment.