Repository: climate Updated Branches: refs/heads/CLIMATE-785 [created] 1903b90a0
CLIMATE-785 - RCMED.py: optimize code Fixes https://issues.apache.org/jira/browse/CLIMATE-785 Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/1903b90a Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/1903b90a Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/1903b90a Branch: refs/heads/CLIMATE-785 Commit: 1903b90a089f31ae531d36ecedf8ab09805cc14a Parents: d854840 Author: Ibrahim <[email protected]> Authored: Fri Apr 29 11:01:55 2016 +0530 Committer: Ibrahim <[email protected]> Committed: Fri Apr 29 11:01:55 2016 +0530 ---------------------------------------------------------------------- ocw/data_source/rcmed.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/1903b90a/ocw/data_source/rcmed.py ---------------------------------------------------------------------- diff --git a/ocw/data_source/rcmed.py b/ocw/data_source/rcmed.py index ee8362c..142a612 100644 --- a/ocw/data_source/rcmed.py +++ b/ocw/data_source/rcmed.py @@ -204,18 +204,10 @@ def _beginning_of_date(time, time_step): if time_step.lower() == 'monthly': if time.day != 1: - start_time_string = time.strftime('%Y%m%d') - start_time_string = start_time_string[:6] + '01' - time = datetime.strptime(start_time_string, '%Y%m%d') - ##TODO: Change the 3 lines above with this line: - ##time = datetime(time.year, time.month, 1) + time = datetime(time.year, time.month, 1) elif time_step.lower() == 'daily': if time.hour != 0 or time.minute != 0 or time.second != 0: - start_time_string = time.strftime('%Y%m%d%H%M%S') - start_time_string = start_time_string[:8] + '000000' - time = datetime.strptime(start_time_string, '%Y%m%d%H%M%S') - ##TODO: Change the 3 lines above with this line: - ##time = datetime(time.year, time.month, time.day, 00, 00, 00) + time = datetime(time.year, time.month, time.day, 00, 00, 00) return time @@ -234,17 +226,9 @@ def _end_of_date(time, time_step): last_day_of_month = calendar.monthrange(time.year, time.month)[1] if time.day != last_day_of_month: - end_time_string = time.strftime('%Y%m%d') - end_time_string = end_time_string[:6] + str(last_day_of_month) - time = datetime.strptime(end_time_string, '%Y%m%d') - ##TODO: Change the 3 lines above with this line: - ##time = datetime(time.year, time.month, lastDayOfMonth) + time = datetime(time.year, time.month, last_day_of_month) elif time_step.lower() == 'daily': - end_time_string = time.strftime('%Y%m%d%H%M%S') - end_time_string = end_time_string[:8] + '235959' - time = datetime.strptime(end_time_string, '%Y%m%d%H%M%S') - ##TODO: Change the 3 lines above with this line: - ##time = datetime(time.year, time.month, end_time.day, 23, 59, 59) + time = datetime(time.year, time.month, end_time.day, 23, 59, 59) return time
