Skip to content

Commit

Permalink
update datetime parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Taoning Wang committed Oct 26, 2023
1 parent fd14e11 commit 86666ae
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions frads/eplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Class and functions for accessing EnergyPlus Python API
"""

from datetime import datetime, timedelta
import datetime
import json
from pathlib import Path
from typing import Dict, List, Optional, Callable, Union
Expand Down Expand Up @@ -323,8 +323,11 @@ def callback_function(state):

return callback_function

def get_datetime(self) -> datetime:
def get_datetime(self) -> datetime.datetime:
"""Get the current date and time from EnergyPlus
Run time datatime format with iso_8601_format = yes.
hour 0-23, minute 10 - 60
v23.2.0
Returns:
datetime object
Expand All @@ -335,7 +338,17 @@ def get_datetime(self) -> datetime:
hour = self.api.exchange.hour(self.state)
minute = self.api.exchange.minutes(self.state)

return datetime(year, month, day, hour, minute)
_date = datetime.date(year, month, day)

if minute == 60:
minute = 0
hour += 1
if hour == 24:
hour = 0
_date += datetime.timedelta(days=1)
_time = datetime.time(hour, minute)

return datetime.datetime.combine(_date, _time)

def run(
self,
Expand Down

0 comments on commit 86666ae

Please sign in to comment.