def test_subtract_time_to_new_transition_repeated(self): dt = pendulum.create(2013, 10, 27, 2, 0, 0, 0, 'Europe/Paris') self.assertPendulum(dt, 2013, 10, 27, 2, 0, 0, 0) self.assertEqual('Europe/Paris', dt.timezone_name) self.assertEqual(3600, dt.offset) self.assertFalse(dt.is_dst) dt = dt.subtract(microseconds=1) self.assertPendulum(dt, 2013, 10, 27, 2, 59, 59, 999999) self.assertEqual('Europe/Paris', dt.timezone_name) self.assertEqual(7200, dt.offset) self.assertTrue(dt.is_dst) dt = pendulum.create(2013, 11, 3, 1, 0, 0, 0, 'America/New_York') self.assertPendulum(dt, 2013, 11, 3, 1, 0, 0, 0) self.assertEqual('America/New_York', dt.timezone_name) self.assertEqual(-5 * 3600, dt.offset) self.assertFalse(dt.is_dst) dt = dt.subtract(microseconds=1) self.assertPendulum(dt, 2013, 11, 3, 1, 59, 59, 999999) self.assertEqual('America/New_York', dt.timezone_name) self.assertEqual(-4 * 3600, dt.offset) self.assertTrue(dt.is_dst)
def test_pickle(self): dt1 = pendulum.create(2016, 11, 18) dt2 = pendulum.create(2016, 11, 20) p = pendulum.period(dt1, dt2) s = pickle.dumps(p) p2 = pickle.loads(s) self.assertEqual(p.start, p2.start) self.assertEqual(p.end, p2.end) self.assertEqual(p.invert, p2.invert) p = pendulum.period(dt2, dt1) s = pickle.dumps(p) p2 = pickle.loads(s) self.assertEqual(p.start, p2.start) self.assertEqual(p.end, p2.end) self.assertEqual(p.invert, p2.invert) p = pendulum.period(dt2, dt1, True) s = pickle.dumps(p) p2 = pickle.loads(s) self.assertEqual(p.start, p2.start) self.assertEqual(p.end, p2.end) self.assertEqual(p.invert, p2.invert)
def duration(rng): """Calculate the number of seconds contained in a by a date Range.""" seconds = 0 early = pendulum.create(1, 1, 1, 0, 0, 0) late = pendulum.create(1, 1, 1, 0, 0, 0) smallest_and_level = None for an_and in sorted(rng._ands): smallest_and_level = an_and.level (early, late) = _add_condition_to_datetimes(an_and, None, early, late) if len(rng._ors) == 0: late = add_to_datetime(late, level_to_datetime_unit(smallest_and_level), 1) seconds += (late - early).total_seconds() else: for grp in rng._ors: erly = early.copy() lte = late.copy() for cnd in sorted(grp): (erly, lte) = _add_condition_to_datetimes(cnd, grp.position, erly, lte) if len(grp) == 1 and cnd.sign == '=': lte = add_to_datetime(lte, level_to_datetime_unit(cnd.level), 1) secs = (lte - erly).total_seconds() assert secs > 0, 'vaccuous condition in group ' + str(grp) seconds += secs return seconds
def computeDuration(source, destination, departure_time, arrival_time): df = pd.read_csv('openFlights.csv') tz1 = df.loc[df['ICAO3']==source, 'timezone'].values[0] tz2 = df.loc[df['ICAO3']==destination, 'timezone'].values[0] departure_time = datetime.datetime.strptime(departure_time, '%Y-%m-%d %H:%M:%S') d_year = int(departure_time.strftime('%#Y')) d_month = int(departure_time.strftime('%#m')) d_day = int(departure_time.strftime('%#d')) d_hour = int(departure_time.strftime('%#H')) d_min = int(departure_time.strftime('%#M')) d_sec = int(departure_time.strftime('%#S')) arrival_time = datetime.datetime.strptime(arrival_time, '%Y-%m-%d %H:%M:%S') a_year = int(arrival_time.strftime('%#Y')) a_month = int(arrival_time.strftime('%#m')) a_day = int(arrival_time.strftime('%#d')) a_hour = int(arrival_time.strftime('%#H')) a_min = int(arrival_time.strftime('%#M')) a_sec = int(arrival_time.strftime('%#S')) dt_source = pendulum.create(d_year, d_month, d_day, d_hour, d_min, d_sec, tz=tz1) dt_destination = pendulum.create(a_year, a_month, a_day, a_hour, a_min, a_sec, tz=tz2) duration = dt_source.diff(dt_destination).in_minutes() return duration
def GetActivities(self, account_id, start, end): start = pendulum.create(start.year, start.month, start.day) end = pendulum.create(end.year, end.month, end.day) json = self._GetRequest('accounts/{}/activities'.format(account_id), { 'startTime': start.isoformat(), 'endTime': end.isoformat() }) print("Get activities from source returned: " + dumps(json)) return json
def test_normalization(self): d1 = pendulum.create(2012, 1, 1, 1, 2, 3, 123456) d2 = pendulum.create(2011, 12, 31, 22, 2, 3) delta = d2 - d1 assert delta.days == 0 assert delta.seconds == -10800 assert delta.microseconds == -123456 assert d1 + delta == d2
def handle(self, **options): self.tenant = options['tenant'] self.to_email = options['email'] activate('en') self.start_date = pendulum.create(options['start'], 1, 1, 0, 0, 0) self.end_date = pendulum.create(options['end'], 12, 31, 23, 59, 59) self.generate_participation_xls()
def test_get_older_than_returns_timestamps_smaller_or_equal(backend): backend.set(pendulum.create(2017, 1, 1, 9), '1', (1, ), {'1': 1}) backend.set(pendulum.create(2017, 1, 1, 10), '2', (2, ), {'2': 2}) backend.set(pendulum.create(2017, 1, 1, 11), '3', (3, ), {'3': 3}) items = list(backend.get_older_than(pendulum.create(2017, 1, 1, 10))) assert len(items) == 2 assert items[0][0] == '1' assert items[0][1] == ((1, ), {'1': 1}) assert items[1][0] == '2' assert items[1][1] == ((2, ), {'2': 2})
def test_partitions_for_daily_schedule_decorators_without_timezone(): with instance_for_test() as instance: with pendulum.test( pendulum.create(2019, 2, 27, 0, 1, 1, tz="US/Central")): context_without_time = ScheduleExecutionContext(instance, None) start_date = datetime(year=2019, month=1, day=1) @daily_schedule( pipeline_name="foo_pipeline", start_date=start_date, execution_time=time(hour=9, minute=30), ) def daily_foo_schedule(daily_time): return {"daily_time": daily_time.isoformat()} _check_partitions( daily_foo_schedule, (31 + 26), start_date, DEFAULT_DATE_FORMAT, relativedelta(days=1), ) valid_daily_time = pendulum.create(year=2019, month=1, day=27, hour=9, minute=30, tz="US/Central") context_with_valid_time = ScheduleExecutionContext( instance, valid_daily_time) execution_data = daily_foo_schedule.get_execution_data( context_with_valid_time) assert len(execution_data) == 1 assert isinstance(execution_data[0], RunRequest) assert execution_data[0].run_config == { "daily_time": pendulum.create(year=2019, month=1, day=26, tz="US/Central").isoformat() } execution_data = daily_foo_schedule.get_execution_data( context_without_time) assert len(execution_data) == 1 assert isinstance(execution_data[0], RunRequest) assert execution_data[0].run_config == { "daily_time": pendulum.create(year=2019, month=2, day=26, tz="US/Central").isoformat() }
def get_date_published(self, obj, types, type_attr='pub-type'): for t in types: pub_date = obj.soup.find('pub-date', **{type_attr: t}) if pub_date: year = pub_date.year month = pub_date.month day = pub_date.day if year and month and day: return str(pendulum.create(int(year.string), int(month.string), int(day.string))) elif year and month: return str(pendulum.create(int(year.string), int(month.string), 1)) if type_attr == 'pub-type': return self.get_date_published(obj, types, 'date-type') return None
def setUp(self): super(ParticipationStatisticsTest, self).setUp() # Required by Project model save method self.init_projects() self.user_1 = BlueBottleUserFactory.create() self.user_2 = BlueBottleUserFactory.create() self.user_3 = BlueBottleUserFactory.create() self.location = LocationFactory.create() self.project_status_plan_new = ProjectPhase.objects.get( slug='plan-new') self.project_status_plan_submitted = ProjectPhase.objects.get( slug='plan-submitted') self.project_status_voting = ProjectPhase.objects.get(slug='voting') self.project_status_voting_done = ProjectPhase.objects.get( slug='voting-done') self.project_status_campaign = ProjectPhase.objects.get( slug='campaign') self.project_status_done_complete = ProjectPhase.objects.get( slug='done-complete') self.project_status_done_incomplete = ProjectPhase.objects.get( slug='done-incomplete') self.project_status_closed = ProjectPhase.objects.get(slug='closed') self.some_project = ProjectFactory.create( owner=self.user_1, status=self.project_status_done_complete, location=self.location) self.another_project = ProjectFactory.create(owner=self.user_2) self.some_task = TaskFactory.create(project=self.some_project, author=self.user_1) self.another_task = TaskFactory.create(project=self.another_project, author=self.user_2) self.some_task_member = TaskMemberFactory.create(member=self.user_1, task=self.some_task) self.another_task_member = TaskMemberFactory.create( member=self.user_2, task=self.another_task) start = pendulum.create().subtract(days=7) end = pendulum.create().add(days=7) # TODO: Create atleast one project, task and task member outside the time range self.statistics = ParticipationStatistics(start=start, end=end)
class DateParserLink(AbstractLink): LOWER_BOUND = pendulum.create(1200, 1, 1) UPPER_BOUND = pendulum.today().add(years=100) DEFAULT = pendulum.create(2016, 1, 1) def execute(self, obj): if obj: date = dateutil.parser.parse(obj, default=self.DEFAULT) repr(date) # Forces tzoffset validation to run if date < self.LOWER_BOUND: raise ValueError('{} is before the lower bound {}.'.format(obj, self.LOWER_BOUND.isoformat())) if date > self.UPPER_BOUND: raise ValueError('{} is after the upper bound {}.'.format(obj, self.UPPER_BOUND.isoformat())) return date.in_tz('UTC').isoformat() raise ValueError('{} is not a valid date.'.format(obj))
def test_partitions_for_weekly_schedule_decorators_without_timezone(): with instance_for_test() as instance: with pendulum.test( pendulum.create(2019, 2, 27, 0, 1, 1, tz="US/Central")): context_without_time = ScheduleExecutionContext(instance, None) start_date = datetime(year=2019, month=1, day=1) @weekly_schedule( pipeline_name="foo_pipeline", execution_day_of_week=2, start_date=start_date, execution_time=time(9, 30), ) def weekly_foo_schedule(weekly_time): return {"weekly_time": weekly_time.isoformat()} valid_weekly_time = datetime(year=2019, month=1, day=30, hour=9, minute=30) context_with_valid_time = ScheduleExecutionContext( instance, valid_weekly_time) assert weekly_foo_schedule.get_run_config( context_with_valid_time) == { "weekly_time": pendulum.create(year=2019, month=1, day=22, tz="US/Central").isoformat() } assert weekly_foo_schedule.should_execute(context_with_valid_time) assert weekly_foo_schedule.get_run_config( context_without_time) == { "weekly_time": pendulum.create(year=2019, month=2, day=19, tz="US/Central").isoformat() } assert weekly_foo_schedule.should_execute(context_without_time) _check_partitions(weekly_foo_schedule, 8, start_date, DEFAULT_DATE_FORMAT, relativedelta(weeks=1))
def _get_date_param(param): if not param: return pendulum.create(1900, 1, 1) if isinstance(param, pendulum.datetime): return param elif isinstance(param, str): return pendulum.parse(param)
def _read_aux(self, titulo_id, params): if isinstance(titulo_id, list): for titulo_id_elto in titulo_id: self._validate_titulo_id(titulo_id_elto) else: self._validate_titulo_id(titulo_id) start_date = pendulum.create(2002, 1, 1, 0, 0, 0) end_date = pendulum.now() group_by_year = False if 'data_inicio' in params: self._validade_date(params['data_inicio']) start_date = pendulum.strptime( '{}-01'.format(params['data_inicio']), '%Y-%m-%d') if 'data_fim' in params: self._validade_date(params['data_fim']) end_date = pendulum.strptime('{}-01'.format(params['data_fim']), '%Y-%m-%d') if 'group_by' in params: assert params['group_by'] in ( 'true', 'false'), '"group_by" must be "true" or "false".' group_by_year = True if params['group_by'] == 'true' else False start_date = start_date.strftime('%Y-%m-%d %H:%M:%S') end_date = end_date.strftime('%Y-%m-%d %H:%M:%S') return (start_date, end_date, group_by_year)
def epoch_to_time(timezone=None): if timezone is None: return time.localtime(epoch) else: local = pendulum.create(2016, 8, 7, 22, 24, 30, tz='Europe/Paris') '2016-08-07T22:24:30+02:00' in_paris.in_timezone('America/New_York')
def test_convert_accept_pendulum_instance(self): dt = pendulum.create(2016, 8, 7, 12, 53, 54) tz = timezone('Europe/Paris') new = tz.convert(dt) self.assertIsInstanceOfPendulum(new) self.assertPendulum(new, 2016, 8, 7, 14, 53, 54)
def test_pendulum_create_basic(self): dt = pendulum.create(2016, 6, 1, 12, 34, 56, 123456, 'Europe/Paris') self.assertPendulum(dt, 2016, 6, 1, 12, 34, 56, 123456) self.assertEqual('Europe/Paris', dt.timezone_name) self.assertEqual(7200, dt.offset) self.assertTrue(dt.is_dst)
def _value_transform(v): # transform dates into timestamps if isinstance(v, datetime) or isinstance(v, pendulum.Pendulum): if isinstance(v, datetime): pv = pendulum.create( v.year, v.month, v.day, v.hour, v.minute, v.second, v.microsecond, v.tzname(), ) else: pv = v return pv.timestamp() # support for special string '@' values elif isinstance(v, str) and len(v) > 0 and v[0] == '@': if v == '@true': return True if v == '@false': return False return v # for a regex, return a Python regex obj elif isinstance(v, str) and len(v) > 0 and v[0] == '~': return re.compile(v[1:]) # default is no transformation else: return v
def test_pendulum_create_repeated(self): dt = pendulum.create(2013, 10, 27, 2, 30, 45, 123456, 'Europe/Paris') self.assertPendulum(dt, 2013, 10, 27, 2, 30, 45, 123456) self.assertEqual('Europe/Paris', dt.timezone_name) self.assertEqual(3600, dt.offset) self.assertFalse(dt.is_dst)
def test_dst_add(): start = pendulum.create(2017, 3, 7, tz='America/Toronto') end = start.add(days=6) period = end - start new_end = start + period assert new_end == end
def test_dst_subtract(): start = pendulum.create(2017, 3, 7, tz='America/Toronto') end = start.add(days=6) period = end - start new_start = end - period assert new_start == start
def test_parse(self): text = '2016-10-16T12:34:56.123456+01:30' dt = pendulum.parse(text) self.assertIsInstanceOfPendulum(dt) self.assertPendulum(dt, 2016, 10, 16, 12, 34, 56, 123456) self.assertEqual(5400, dt.offset) text = '2016-10-16' dt = pendulum.parse(text) self.assertIsInstanceOfPendulum(dt) self.assertPendulum(dt, 2016, 10, 16, 0, 0, 0, 0) self.assertEqual(0, dt.offset) with self.wrap_with_test_now(pendulum.create(2015, 11, 12)): text = '12:34:56.123456' dt = pendulum.parse(text) self.assertIsInstanceOfPendulum(dt) self.assertPendulum(dt, 2015, 11, 12, 12, 34, 56, 123456) self.assertEqual(0, dt.offset)
def test_pendulum_create_skipped(self): dt = pendulum.create(2013, 3, 31, 2, 30, 45, 123456, 'Europe/Paris') self.assertPendulum(dt, 2013, 3, 31, 3, 30, 45, 123456) self.assertEqual('Europe/Paris', dt.timezone_name) self.assertEqual(7200, dt.offset) self.assertTrue(dt.is_dst)
def test_partitions_for_weekly_schedule_decorators_with_timezone(): with instance_for_test() as instance: with pendulum.test( pendulum.create(2019, 2, 27, 0, 1, 1, tz="US/Central")): start_date = datetime(year=2019, month=1, day=1) @weekly_schedule( pipeline_name="foo_pipeline", execution_day_of_week=3, start_date=start_date, execution_time=time(9, 30), execution_timezone="US/Central", ) def weekly_foo_schedule(weekly_time): return {"weekly_time": weekly_time.isoformat()} assert weekly_foo_schedule.execution_timezone == "US/Central" valid_weekly_time = pendulum.create(year=2019, month=1, day=30, hour=9, minute=30, tz="US/Central") context_with_valid_time = ScheduleExecutionContext( instance, valid_weekly_time) execution_data = weekly_foo_schedule.get_execution_data( context_with_valid_time) assert len(execution_data) == 1 assert isinstance(execution_data[0], RunRequest) assert execution_data[0].run_config == { "weekly_time": pendulum.create(year=2019, month=1, day=22, tz="US/Central").isoformat() } _check_partitions( weekly_foo_schedule, 8, pendulum.instance(start_date, tz="US/Central"), DEFAULT_DATE_FORMAT, relativedelta(weeks=1), )
def test__get_months_to_process02(): """ can we get the list of months to process when we roll over a year? """ fake_now = pendulum.create(2018, 1, 4) result = object_under_test._get_months_to_process(3, fake_now) assert len(result) == 3 result.index((2017, 11)) result.index((2017, 12)) result.index((2018, 1))
def get_date_published(self, obj, types, type_attr='pub-type'): for t in types: pub_date = obj.soup.find('pub-date', **{type_attr: t}) if pub_date: year = pub_date.year month = pub_date.month day = pub_date.day if year and month and day: return str( pendulum.create(int(year.string), int(month.string), int(day.string))) elif year and month: return str( pendulum.create(int(year.string), int(month.string), 1)) if type_attr == 'pub-type': return self.get_date_published(obj, types, 'date-type') return None
def check_record_date(self, issue_date, start_date, end_date): date_object = dateutil.parser.parse(issue_date, default=pendulum.create(2016, 1, 1)) if date_object < start_date.start_of('day'): return 'before' if date_object > end_date.end_of('day'): return 'after' return 'within'
def test__get_months_to_process03(): """ can we get the list of months to process when we're at the end of a month that's longer than the previous? """ fake_now = pendulum.create(2018, 4, 30) result = object_under_test._get_months_to_process(3, fake_now) assert len(result) == 3 result.index((2018, 2)) result.index((2018, 3)) result.index((2018, 4))
def test__get_months_to_process01(): """ can we get the list of months to process when they're in the same year? """ fake_now = pendulum.create(2018, 3, 4) result = object_under_test._get_months_to_process(3, fake_now) assert len(result) == 3 result.index((2018, 1)) result.index((2018, 2)) result.index((2018, 3))
def test_set_test_now_can_be_overridden(self): now = pendulum.create(2000, 11, 10, 12, 34, 56, 123456) pendulum.set_test_now(now) dt = pendulum.create(2001, 12, 11, 1, 2, 3, 987654) pendulum.Pendulum.set_test_now(dt) pendulum.Date.set_test_now(dt) pendulum.Time.set_test_now(dt) self.assertEqual(now, pendulum.get_test_now()) self.assertEqual(dt, pendulum.Pendulum.get_test_now()) self.assertEqual(dt.date(), pendulum.Date.get_test_now()) self.assertEqual(dt.time(), pendulum.Time.get_test_now()) self.assertPendulum(pendulum.Pendulum.now(), 2001, 12, 11, 1, 2, 3, 987654) self.assertDate(pendulum.Date.today(), 2001, 12, 11) self.assertTime(pendulum.Time.now(), 1, 2, 3, 987654)
def starttime(t): """ Fixes the start time of observations taken with LAT. This assumes that the time array in your light curve is in days already, and the beginning of your analysis coincides with t0 for LAT. :param t: array with input times given in days, with t0 coinciding with the beginning of LAT :returns: t (days), t (years) """ import pendulum # start of observations by Fermi tp=pendulum.create(2008,8,4,15,43,37)-pendulum.create(2008,1,1) t0=tp.days # how many days since 2008 for the beginning of Fermi observations t=t-t[0]+t0 # fixes t array ty=2008.+t/365. # time in years return t,ty
def get_supplier_responses(self, code): responses = db.session.query(BriefResponse.created_at.label('response_date'), Brief.id, Brief.data['title'].astext.label('name'), Lot.name.label('framework'), Brief.closed_at, case([(AuditEvent.type == 'read_brief_responses', True)], else_=False) .label('is_downloaded'))\ .distinct(Brief.closed_at, Brief.id)\ .join(Brief, Lot)\ .outerjoin(AuditEvent, and_(Brief.id == AuditEvent.data['briefId'].astext.cast(Numeric), AuditEvent.type == 'read_brief_responses'))\ .filter(BriefResponse.supplier_code == code, Brief.closed_at > pendulum.create(2018, 1, 1), BriefResponse.withdrawn_at.is_(None) )\ .order_by(Brief.closed_at, Brief.id)\ .all() return [r._asdict() for r in responses]
#skip the last header line head = next(reader) blist = [] lastel = -1 br = False while True: rowlist = [] while True: try: row = next(reader) except: sys.exit(1) #create a datetime time = pendulum.create(int(row[YEAR]),int(row[MONTH]),int(row[DAY]),int(row[HOUR]),int(row[MINUTE]),0,0) #get the recorded zenith #zenith = float(row[ZENITH]) #get the elevation and azimuth from pysolar elevation = pysolar.solar.get_altitude(lat, lon, time) if (lastel > 0 and elevation < 0): br = True lastel = elevation #get azimuth from pysolar azimuth = pysolar.solar.get_azimuth(lat, lon, time)
def irr_parser(inputs): print(inputs) input_fname = inputs[0] output_fname = inputs[1] def azel_to_thetaphi(az, el): """ Az-El to Theta-Phi conversion. Args: az (float or np.array): Azimuth angle, in radians el (float or np.array): Elevation angle, in radians Returns: (theta, phi): Tuple of corresponding (theta, phi) angles, in radians """ el = np.deg2rad(el) az = np.deg2rad(az) cos_theta = np.cos(el) * np.cos(az) tan_phi = np.tan(el) / np.sin(az) theta = np.arccos(cos_theta) phi = np.arctan2(np.tan(el), np.sin(az)) phi = (phi + 2 * np.pi) % (2 * np.pi) return np.rad2deg(theta), np.rad2deg(phi) YEAR = 0 MONTH = 1 DAY = 2 HOUR = 3 MINUTE = 4 DHI = 5 DNI = 6 GHI = 7 CLEAR_DHI = 8 ZENITH = 12 with open(output_fname, 'w') as out: with open(input_fname, 'r') as f: reader = csv.reader(f) #skip the first header line head = next(reader) #grab the lat/lon from the next one head = next(reader) lat = float(head[5]) lon = float(head[6]) out.write('Signpost power data at ' + str(lat) + ',' + str(lon) + '\n') out.write('Date, South Power, West Power, North Power, East Power\n') #skip the last header line head = next(reader) for row in reader: #create a datetime time = pendulum.create(int(row[YEAR]),int(row[MONTH]),int(row[DAY]),int(row[HOUR]),int(row[MINUTE]),0,0) #get the recorded zenith #zenith = float(row[ZENITH]) #get the elevation and azimuth from pysolar elevation = pysolar.solar.get_altitude(lat, lon, time) #get azimuth from pysolar azimuth = pysolar.solar.get_azimuth(lat, lon, time) #now transpose the elevation and azimuth calculations into a theta #angle for one of the cardinal directions #to do this flip around the azimuth (it is south referenced) #if the angle is > 90, there is effectively zero direct sunlight #so just cap it at 90 to make the cos(angle) calc easy #south southangle, nop = azel_to_thetaphi(azimuth, elevation) #east eastangle, nop = azel_to_thetaphi(azimuth-90, elevation) #west westangle, nop = azel_to_thetaphi(azimuth+90, elevation) #north northangle, nop = azel_to_thetaphi(azimuth-180, elevation) #now we can calculate the predicted solar irradiation for signpost on that #day #then we can multiply that my size and efficiency for the final prediction #predicted irradiation = DNI*cos(solar_angle) + DHI dni = float(row[DNI]) dhi = float(row[DHI]) angles = np.array([southangle, westangle, northangle, eastangle]) factors = np.cos(np.deg2rad(angles)) mask = factors < 0 factors[mask] = 0 if(dhi > dni): irradiances = dni*factors + dhi*factors else: irradiances = dni*factors + dhi*0.5 #efficiency of our solar panel solar_eff = 0.17 #size in m^2 size = 0.096 #predicted power output for signpost at this time in our input data powers = irradiances*size*solar_eff #now we should print this to the output csv out.write(time.strftime("%m/%d/%Y %H:%M") + ',' + str(powers[0]) + ',' + str(powers[1]) + ',' + str(powers[2]) + ',' + str(powers[3]) + '\n')
#!/usr/bin/env python3 import pendulum # Pendulum docs at https://pendulum.eustace.io/docs/ #/9** dt_ny = pendulum.create(2017,2,22, tz='America/New_York') dt_vancouver = pendulum.create(2017,2,22, tz='America/Vancouver') print(dt_ny) print(dt_vancouver) print(dt_vancouver.diff(dt_ny).in_hours()) print(dt_vancouver.diff_for_humans(dt_ny)) print(dt_ny.diff_for_humans(dt_vancouver)) today = pendulum.now() print(today) print(today.to_date_string()) print(today.to_formatted_date_string()) print(today.to_time_string()) print(today.to_datetime_string()) print(today.to_day_datetime_string()) print(today.format('%A %d%_t of %B %Y %I:%M:%S %p')) print(today.strftime('%A %d of %B %Y %I:%M:%S %p'))