本文整理汇总了Python中time.struct_time函数的典型用法代码示例。如果您正苦于以下问题:Python struct_time函数的具体用法?Python struct_time怎么用?Python struct_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了struct_time函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_creates_item_from_given_data
def test_creates_item_from_given_data(self):
data = dict(
guid='http://news.com/rss/1234abcd',
published_parsed=struct_time([2015, 2, 25, 16, 45, 23, 2, 56, 0]),
updated_parsed=struct_time([2015, 2, 25, 17, 52, 11, 2, 56, 0]),
title='Breaking News!',
summary='Something happened...',
body_text='This is body text.',
author='author',
)
item = self.instance._create_item(data, source='source')
self.assertEqual(item.get('guid'), 'http://news.com/rss/1234abcd')
self.assertEqual(item.get('uri'), 'http://news.com/rss/1234abcd')
self.assertEqual(item.get('type'), 'text')
self.assertEqual(
item.get('firstcreated'), datetime(2015, 2, 25, 16, 45, 23))
self.assertEqual(
item.get('versioncreated'), datetime(2015, 2, 25, 17, 52, 11))
self.assertEqual(item.get('headline'), 'Breaking News!')
self.assertEqual(item.get('abstract'), 'Something happened...')
self.assertEqual(item.get('body_html'),
'<p><a href="http://news.com/rss/1234abcd" target="_blank">source</a></p>This is body text.')
self.assertEqual(item.get('byline'), 'author')
dateline = item.get('dateline', {})
self.assertEqual(dateline.get('source'), 'source')
self.assertEqual(dateline.get('date'), item.get('firstcreated'))
开发者ID:sjunaid,项目名称:superdesk-core,代码行数:28,代码来源:rss_test.py
示例2: knox
def knox(x1, y1, t1, x2, y2, t2, dist_scale, time_scale_days, nrand=1000, verbose=True):
'''Compute the Knox test statistic:
X = # events near in space and time versus time-permuted'''
# First get rid of points where the spatial location is undefined.
t1leads=True
wh1 = np.where(~np.isnan(x1))
wh2 = np.where(~np.isnan(x2))
x1, y1, t1 = x1[wh1], y1[wh1], t1[wh1]
x2, y2, t2 = x2[wh2], y2[wh2], t2[wh2]
# Now compute the times in seconds for easy math.
t1 = np.array([time.mktime(time.struct_time(i)) for i in t1])
t2 = np.array([time.mktime(time.struct_time(i)) for i in t2])
time_scale = time_scale_days * 24 * 3600
# Determine the array sizes. We're going to be looping over (x1,y1,t1),
# so make sure that's the shorter of the two data sets to take maximal
# advantage of numpy's parallelization for vectorized operations.
Nd1 = len(t1)
Nd2 = len(t2)
if Nd1 > Nd2:
x3, y3, t3, Nd3 = x1, y1, t1, Nd1
x1, y1, t1, Nd1 = x2, y2, t2, Nd2
x2, y2, t2, Nd2 = x3, y3, t3, Nd3
t1leads = False
# Compute the test statistic for the real data and the randomized data.
X, randX = compute_test_statistic(x1, y1, t1, Nd1, x2, y2, t2, Nd2, \
dist_scale, time_scale, nrand=nrand, t1leads=t1leads, verbose=verbose)
# OK, we're done now.
return X, randX
开发者ID:dssg,项目名称:publicsafety,代码行数:32,代码来源:knox_onesided.py
示例3: main
def main():
# Script outline
#
# 1. When is the object visible from Paranal?
# 2. Is it visible within 4 hours after the trigger?
# 3. Is it visible long enough (~ 1hr)
RA = "23:18:11.57"
DEC = "32:28:31.8"
EQUINOX = "J2000"
# Format for my script = ?!? skycat!!!
#TRIGGER =
# Example usage
# Set the observatory information and calc twilights
GRB = CelestialObject()
GRB.setObservatory(siteabbrev='e')
intime = time.gmtime(time.time())
intime = time.struct_time(intime[0:9])
timestruct = time.struct_time(intime)
GRB.computeTwilights()
GRB.computeNightLength()
GRB.printInfo()
intime = intime[0:6]
print ""
print "Given date: %s-%s-%s\t %s:%s:%s UT" % (intime[0], intime[1], intime[2], intime[3], intime[4], intime[5])
开发者ID:jonnybazookatone,项目名称:hawki,代码行数:27,代码来源:vlad.py
示例4: test_inactive_date
def test_inactive_date(self):
## fixed day:
self.assertEqual(
OrgFormat.inactive_date(time.struct_time([1980,12,31,0,0,0,0,0,0])),
u'[1980-12-31 Wed]' )
## fixed time with seconds:
self.assertEqual(
OrgFormat.inactive_date(time.struct_time([1980,12,31,23,59,58,0,0,0]), 'foo'),
u'[1980-12-31 Wed 23:59]' ) ## seconds are not (yet) defined in Org-mode
## fixed time without seconds:
self.assertEqual(
OrgFormat.inactive_date(time.struct_time([1980,12,31,23,59,0,0,0,0]), 'foo'),
u'[1980-12-31 Wed 23:59]' )
YYYYMMDDwday = time.strftime('%Y-%m-%d %a', time.localtime())
hhmmss = time.strftime('%H:%M', time.localtime()) ## seconds are not (yet) defined in Org-mode
## simple form with current day:
self.assertEqual(
OrgFormat.inactive_date(time.localtime()),
u'[' + YYYYMMDDwday + u']' )
## show_time parameter not named:
self.assertEqual(
OrgFormat.inactive_date(time.localtime(), True),
u'[' + YYYYMMDDwday + u' ' + hhmmss + u']' )
## show_time parameter named:
self.assertEqual(
OrgFormat.inactive_date(time.localtime(), show_time=True),
u'[' + YYYYMMDDwday + u' ' + hhmmss + u']' )
开发者ID:andrewjss,项目名称:Memacs,代码行数:34,代码来源:orgformat_test.py
示例5: test_does_not_use_body_text_populate_fallback_if_aliased
def test_does_not_use_body_text_populate_fallback_if_aliased(self):
class CustomDict(dict):
"""Customized dict class, allows adding custom attributes to it."""
data = CustomDict(
guid='http://news.com/rss/1234abcd',
published_parsed=struct_time([2015, 2, 25, 16, 45, 23, 2, 56, 0]),
updated_parsed=struct_time([2015, 2, 25, 17, 52, 11, 2, 56, 0]),
title='Breaking News!',
summary='Something happened...',
# NOTE: no body_text field
)
content_field = [
CustomDict(type='text/html', value='<p>This is body</p>')
]
content_field[0].value = '<p>This is body</p>'
data.content = content_field
field_aliases = [{'body_text': 'body_text_field_alias'}]
data.body_text_field_alias = None # simulate non-existing alias field
item = self.instance._create_item(data, field_aliases)
self.assertEqual(item.get('body_html'),
'<p><a href="http://news.com/rss/1234abcd" target="_blank">source</a></p>')
开发者ID:liveblog,项目名称:superdesk-core,代码行数:26,代码来源:rss_test.py
示例6: test_returns_items_built_from_retrieved_data
def test_returns_items_built_from_retrieved_data(self):
feed_parse.return_value = MagicMock(
entries=[
MagicMock(
updated_parsed=struct_time(
[2015, 2, 25, 17, 11, 11, 2, 56, 0])
),
MagicMock(
updated_parsed=struct_time(
[2015, 2, 25, 17, 22, 22, 2, 56, 0])
),
]
)
item_1 = dict(
guid='item_1',
firstcreated=datetime(2015, 2, 25, 17, 11, 11),
versioncreated=datetime(2015, 2, 25, 17, 11, 11),
)
item_2 = dict(
guid='item_2',
firstcreated=datetime(2015, 2, 25, 17, 22, 22),
versioncreated=datetime(2015, 2, 25, 17, 22, 22),
)
self.instance._create_item.side_effect = [item_1, item_2]
returned = self.instance._update(
{'last_updated': datetime(2015, 2, 25, 14, 0, 0)}
)
self.assertEqual(len(returned), 1)
items = returned[0]
self.assertEqual(items, [item_1, item_2])
开发者ID:liveblog,项目名称:superdesk-core,代码行数:33,代码来源:rss_test.py
示例7: test_creates_item_taking_field_name_aliases_into_account
def test_creates_item_taking_field_name_aliases_into_account(self):
data = dict(
guid='http://news.com/rss/1234abcd',
published_parsed=struct_time([2015, 2, 25, 16, 45, 23, 2, 56, 0]),
updated_parsed=struct_time([2015, 2, 25, 17, 52, 11, 2, 56, 0]),
title_field_alias='Breaking News!',
summary_field_alias='Something happened...',
body_text_field_alias='This is body text.',
)
field_aliases = [{'title': 'title_field_alias'},
{'summary': 'summary_field_alias'},
{'body_text': 'body_text_field_alias'}]
item = self.instance._create_item(data, field_aliases)
self.assertEqual(item.get('guid'), 'http://news.com/rss/1234abcd')
self.assertEqual(item.get('uri'), 'http://news.com/rss/1234abcd')
self.assertEqual(item.get('type'), 'text')
self.assertEqual(
item.get('firstcreated'), datetime(2015, 2, 25, 16, 45, 23))
self.assertEqual(
item.get('versioncreated'), datetime(2015, 2, 25, 17, 52, 11))
self.assertEqual(item.get('headline'), 'Breaking News!')
self.assertEqual(item.get('abstract'), 'Something happened...')
self.assertEqual(item.get('body_html'),
'<p><a href="http://news.com/rss/1234abcd" target="_blank">source</a></p>This is body text.')
开发者ID:liveblog,项目名称:superdesk-core,代码行数:27,代码来源:rss_test.py
示例8: test_inactive_date
def test_inactive_date(self):
## fixed day:
self.assertEqual(
OrgFormat.inactive_date(time.struct_time([1980,12,31,0,0,0,0,0,0])),
u'[1980-12-31 Mon]' ) ## however, it was a Wednesday
## fixed time with seconds:
self.assertEqual(
OrgFormat.inactive_date(time.struct_time([1980,12,31,23,59,58,0,0,0]), 'foo'),
u'[1980-12-31 Mon 23:59:58]' ) ## however, it was a Wednesday
## fixed time without seconds:
self.assertEqual(
OrgFormat.inactive_date(time.struct_time([1980,12,31,23,59,0,0,0,0]), 'foo'),
u'[1980-12-31 Mon 23:59]' ) ## however, it was a Wednesday
YYYYMMDDwday = time.strftime('%Y-%m-%d %a', time.localtime())
hhmmss = time.strftime('%H:%M:%S', time.localtime())
## simple form with current day:
self.assertEqual(
OrgFormat.inactive_date(time.localtime()),
u'[' + YYYYMMDDwday + u']' )
## show_time parameter not named:
self.assertEqual(
OrgFormat.inactive_date(time.localtime(), True),
u'[' + YYYYMMDDwday + u' ' + hhmmss + u']' )
## show_time parameter named:
self.assertEqual(
OrgFormat.inactive_date(time.localtime(), show_time=True),
u'[' + YYYYMMDDwday + u' ' + hhmmss + u']' )
开发者ID:ajft,项目名称:Memacs,代码行数:34,代码来源:orgformat_test.py
示例9: _parse_gpgga
def _parse_gpgga(self, args):
# Parse the arguments (everything after data type) for NMEA GPGGA
# 3D location fix sentence.
data = args.split(',')
if data is None or len(data) != 14:
return # Unexpected number of params.
# Parse fix time.
time_utc = int(_parse_float(data[0]))
if time_utc is not None:
hours = time_utc // 10000
mins = (time_utc // 100) % 100
secs = time_utc % 100
# Set or update time to a friendly python time struct.
if self.timestamp_utc is not None:
self.timestamp_utc = time.struct_time((
self.timestamp_utc.tm_year, self.timestamp_utc.tm_mon,
self.timestamp_utc.tm_mday, hours, mins, secs, 0, 0, -1))
else:
self.timestamp_utc = time.struct_time((0, 0, 0, hours, mins,
secs, 0, 0, -1))
# Parse latitude and longitude.
self.latitude = _parse_degrees(data[1])
if self.latitude is not None and \
data[2] is not None and data[2].lower() == 's':
self.latitude *= -1.0
self.longitude = _parse_degrees(data[3])
if self.longitude is not None and \
data[4] is not None and data[4].lower() == 'w':
self.longitude *= -1.0
# Parse out fix quality and other simple numeric values.
self.fix_quality = _parse_int(data[5])
self.satellites = _parse_int(data[6])
self.horizontal_dilution = _parse_float(data[7])
self.altitude_m = _parse_float(data[8])
self.height_geoid = _parse_float(data[10])
开发者ID:eiselekd,项目名称:hw,代码行数:35,代码来源:adafruit_gps.py
示例10: test_buttgmt
def test_buttgmt(self):
self.receive_message('/buttgmt +3')
self.assertReplied('Timezone set to GMT+3')
self.test_buttmeon(status=u'''\
Butt enabled, use /buttmeoff to disable it.
Your timezone is set to *GMT+3*, use /buttgmt to change it.''')
import mock
import time
with mock.patch(
'time.gmtime',
return_value=time.struct_time((2016, 1, 18, 9, 50, 36, 0, 18, 0))
):
self.clear_queues()
self.plugin.cron_go('instagram.butt')
self.assertNoReplies()
with mock.patch(
'time.gmtime',
return_value=time.struct_time((2016, 1, 18, 6, 50, 36, 0, 18, 0))
):
self.plugin.cron_go('instagram.butt')
self.assertEqual(self.pop_reply()[1]['caption'], 'Good morning!')
self.receive_message('/buttgmt -5')
self.assertReplied('Timezone set to GMT-5')
with mock.patch(
'time.gmtime',
return_value=time.struct_time((2016, 1, 18, 18, 50, 36, 0, 18, 0))
):
self.plugin.cron_go('instagram.butt')
self.assertEqual(self.pop_reply()[1]['caption'], 'Bon appetit!')
开发者ID:fopina,项目名称:tgbot-buttiebot,代码行数:34,代码来源:test_instagram.py
示例11: checkMakeNewFileName
def checkMakeNewFileName(self):
'''
Routine to check if we need a new filename and to create one if so.
Uses the increment flag (default is daily) to determine how often to
create a new file.
2014-07-17 C. Wingard Added code to create files based on either
daily or hourly increments. Adds time to base
file name.
'''
time_value = gmtime()
time_string = strftime('%Y%m%dT%H%M', time_value) + '_UTC.dat'
if self.increment == 'hourly':
# check if the hour of the day has changed or if this is the first
# time we've run this (e.g. hourOfDay == -1)
if self.hourOfDay != struct_time(time_value).tm_hour:
# create a new filename string
self.fileName = self.basename + '_' + time_string
# update current day of month
self.hourOfDay = struct_time(time_value).tm_hour
if self.increment == 'daily':
# check if the day of month has changed or if this is the first
# time we've run this (e.g. dayOfMonth == -1)
if self.dayOfMonth != struct_time(time_value).tm_mday:
# create a new filename string
self.fileName = self.basename + '_' + time_string
# update current day of month
self.dayOfMonth = struct_time(time_value).tm_mday
开发者ID:cwingard,项目名称:cabled,代码行数:32,代码来源:logger.py
示例12: get_today_condition
def get_today_condition(user):
now_time = time.localtime()
last_time = time.mktime(time.struct_time([now_time.tm_year, now_time.tm_mon, now_time.tm_mday, 0, 0, 0, 0, 0, 0])) - 12 * 3600
today = now_time.tm_mday
last_time = time.localtime(last_time)
start_time = process_num(last_time.tm_year) + "-" + process_num(last_time.tm_mon) + "-" + process_num(last_time.tm_mday) + " " + process_num(last_time.tm_hour) + ":" + process_num(last_time.tm_min) + ":" + process_num(last_time.tm_sec)
end_time = process_num(now_time.tm_year) + "-" + process_num(now_time.tm_mon) + "-" + process_num(now_time.tm_mday) + " " + process_num(now_time.tm_hour) + ":" + process_num(now_time.tm_min) + ":" + process_num(now_time.tm_sec)
data = get_data(["user", 'startTime', 'endTime', 'type', 'distance', 'calories', 'steps', 'subType', 'actTime', 'nonActTime', 'dsNum', 'lsNum', 'wakeNum', 'wakeTimes', 'score'], start_time, end_time, user.id, raw=True)
i = 0
length = len(data)
while data[i]["endTime"].split('-')[2].split(' ')[0] != str(today) and i < length:
data.pop(0)
new_data = integrate_by_class(data)
calculate_time(new_data)
new_data.pop(0)
time_first = new_data[0]["endTime"].split('-')[2].split(' ')[1].split(':')
time_first = time.mktime(time.struct_time([now_time.tm_year, now_time.tm_mon, now_time.tm_mday, int(time_first[0]), int(time_first[1]), int(time_first[2]), 0, 0, 0]))
time_00 = time.mktime(time.struct_time([now_time.tm_year, now_time.tm_mon, now_time.tm_mday, 0, 0, 0, 0, 0, 0]))
rate = float(time_first - time_00) / new_data[0]["allTime"]
new_data[0]["allTime"] -= (time_first - time_00)
new_data[0]["startTime"] = (str(now_time.tm_year) + "-" + str(now_time.tm_mon) + "-" + str(now_time.tm_mday) + " " + "00:00:00").encode("utf-8")
new_data[0]["distance"] = int(new_data[0]["distance"] * rate)
new_data[0]["steps"] = int(new_data[0]["steps"] * rate)
new_data[0]["calories"] = int(new_data[0]["calories"] * rate)
new_data[0]["dsNum"] = int(new_data[0]["dsNum"] * rate)
new_data[0]["sleepNum"] = int(new_data[0]["sleepNum"] * rate)
return new_data
开发者ID:xujingao13,项目名称:weixin,代码行数:27,代码来源:data.py
示例13: test_old_due_date_format
def test_old_due_date_format(self):
current = datetime.datetime.today()
self.assertEqual(
time.struct_time((current.year, 3, 12, 12, 0, 0, 1, 71, 0)),
DateTest.date.from_json("March 12 12:00"))
self.assertEqual(
time.struct_time((current.year, 12, 4, 16, 30, 0, 2, 338, 0)),
DateTest.date.from_json("December 4 16:30"))
开发者ID:hughdbrown,项目名称:edx-platform,代码行数:8,代码来源:test_fields.py
示例14: align_sleep_time
def align_sleep_time():
now_time = time.localtime()
if now_time.tm_hour > 12 or (now_time.tm_hour == 12 and now_time.tm_min > 1):
next_time = time.mktime(time.struct_time([now_time.tm_year, now_time.tm_mon, now_time.tm_mday, 12, 1, 0, 0, 0, 0]))
next_time += 24 * 3600
else:
next_time = time.mktime(time.struct_time([now_time.tm_year, now_time.tm_mon, now_time.tm_mday, 12, 1, 0, 0, 0, 0]))
return (next_time - time.time())
开发者ID:caozhangjie,项目名称:weixin,代码行数:8,代码来源:get_data_url.py
示例15: _strict_date
def _strict_date(self, lean):
py = self._precise_year()
if lean == EARLIEST:
return struct_time(
[py, 1, 1] + TIME_EMPTY_TIME + TIME_EMPTY_EXTRAS)
else:
return struct_time(
[py, 12, 31] + TIME_EMPTY_TIME + TIME_EMPTY_EXTRAS)
开发者ID:ixc,项目名称:python-edtf,代码行数:8,代码来源:parser_classes.py
示例16: _parse_gprmc
def _parse_gprmc(self, args):
# Parse the arguments (everything after data type) for NMEA GPRMC
# minimum location fix sentence.
data = args.split(',')
if data is None or len(data) < 11 or data[0] is None:
return # Unexpected number of params.
# Parse fix time.
time_utc = int(_parse_float(data[0]))
if time_utc is not None:
hours = time_utc // 10000
mins = (time_utc // 100) % 100
secs = time_utc % 100
# Set or update time to a friendly python time struct.
if self.timestamp_utc is not None:
self.timestamp_utc = time.struct_time((
self.timestamp_utc.tm_year, self.timestamp_utc.tm_mon,
self.timestamp_utc.tm_mday, hours, mins, secs, 0, 0, -1))
else:
self.timestamp_utc = time.struct_time((0, 0, 0, hours, mins,
secs, 0, 0, -1))
# Parse status (active/fixed or void).
status = data[1]
self.fix_quality = 0
if status is not None and status.lower() == 'a':
self.fix_quality = 1
# Parse latitude and longitude.
self.latitude = _parse_degrees(data[2])
if self.latitude is not None and \
data[3] is not None and data[3].lower() == 's':
self.latitude *= -1.0
self.longitude = _parse_degrees(data[4])
if self.longitude is not None and \
data[5] is not None and data[5].lower() == 'w':
self.longitude *= -1.0
# Parse out speed and other simple numeric values.
self.speed_knots = _parse_float(data[6])
self.track_angle_deg = _parse_float(data[7])
# Parse date.
if data[8] is not None and len(data[8]) == 6:
day = int(data[8][0:2])
month = int(data[8][2:4])
year = 2000 + int(data[8][4:6]) # Y2k bug, 2 digit date assumption.
# This is a problem with the NMEA
# spec and not this code.
if self.timestamp_utc is not None:
# Replace the timestamp with an updated one.
# (struct_time is immutable and can't be changed in place)
self.timestamp_utc = time.struct_time((year, month, day,
self.timestamp_utc.tm_hour,
self.timestamp_utc.tm_min,
self.timestamp_utc.tm_sec,
0,
0,
-1))
else:
# Time hasn't been set so create it.
self.timestamp_utc = time.struct_time((year, month, day, 0, 0,
0, 0, 0, -1))
开发者ID:eiselekd,项目名称:hw,代码行数:58,代码来源:adafruit_gps.py
示例17: __calc_date_time
def __calc_date_time(self):
# Set self.date_time, self.date, & self.time by using
# time.strftime().
# Use (1999,3,17,22,44,55,2,76,0) for magic date because the amount of
# overloaded numbers is minimized. The order in which searches for
# values within the format string is very important; it eliminates
# possible ambiguity for what something represents.
time_tuple = time.struct_time((1999, 3, 17, 22, 44, 55, 2, 76, 0))
date_time = [None, None, None]
date_time[0] = time.strftime("%c", time_tuple).lower()
date_time[1] = time.strftime("%x", time_tuple).lower()
date_time[2] = time.strftime("%X", time_tuple).lower()
replacement_pairs = [
("%", "%%"),
(self.f_weekday[2], "%A"),
(self.f_month[3], "%B"),
(self.a_weekday[2], "%a"),
(self.a_month[3], "%b"),
(self.am_pm[1], "%p"),
("1999", "%Y"),
("99", "%y"),
("22", "%H"),
("44", "%M"),
("55", "%S"),
("76", "%j"),
("17", "%d"),
("03", "%m"),
("3", "%m"),
# '3' needed for when no leading zero.
("2", "%w"),
("10", "%I"),
]
replacement_pairs.extend([(tz, "%Z") for tz_values in self.timezone for tz in tz_values])
for offset, directive in ((0, "%c"), (1, "%x"), (2, "%X")):
current_format = date_time[offset]
for old, new in replacement_pairs:
# Must deal with possible lack of locale info
# manifesting itself as the empty string (e.g., Swedish's
# lack of AM/PM info) or a platform returning a tuple of empty
# strings (e.g., MacOS 9 having timezone as ('','')).
if old:
current_format = current_format.replace(old, new)
# If %W is used, then Sunday, 2005-01-03 will fall on week 0 since
# 2005-01-03 occurs before the first Monday of the year. Otherwise
# %U is used.
time_tuple = time.struct_time((1999, 1, 3, 1, 1, 1, 6, 3, 0))
if "00" in time.strftime(directive, time_tuple):
U_W = "%W"
else:
U_W = "%U"
date_time[offset] = current_format.replace("11", U_W)
self.LC_date_time = date_time[0]
self.LC_date = date_time[1]
self.LC_time = date_time[2]
开发者ID:Asemco,项目名称:Arrowbots,代码行数:55,代码来源:_strptime.py
示例18: test_struct_time_to_jd
def test_struct_time_to_jd(self):
# Check conversion of AD date & time to Julian Date number
st_ad = struct_time(
[2018, 4, 19] + [10, 13, 54] + convert.TIME_EMPTY_EXTRAS)
jd_ad = 2458227.9263194446
self.assertEqual(jd_ad, convert.struct_time_to_jd(st_ad))
# Check conversion of BC date & time to Julian Date number
st_bc = struct_time(
[-2018, 4, 19] + [10, 13, 54] + convert.TIME_EMPTY_EXTRAS)
jd_bc = 984091.9263194444
self.assertEqual(jd_bc, convert.struct_time_to_jd(st_bc))
开发者ID:ixc,项目名称:python-edtf,代码行数:11,代码来源:tests.py
示例19: checkMakeNewFileName
def checkMakeNewFileName( self ):
"""
Routine to check if we need a new filename and to create one if so
"""
timevalue = gmtime()
# if day of month has change or this is the first time (dayOfMonth == 0)
if self.dayOfMonth != struct_time( timevalue ).tm_mday: #tested w/ tm_hour
# create a new filename string
self.fileName = self.baseFileName + "_" + strftime("%Y%m%d", timevalue) + "_UTC.txt" #_%H%M%S
# update current day of month
self.dayOfMonth = struct_time( timevalue ).tm_mday #tested w/ tm_hour
开发者ID:cwingard,项目名称:cabled,代码行数:11,代码来源:logger.py
示例20: test_podcast_and_episode
def test_podcast_and_episode():
episode_storage = DummyEpisodeStorage()
name = "name"
feed = "http://example.com/feed.xml"
podcast = Podcast(name, feed, episode_storage)
assert podcast.name == name
assert podcast.feed == feed
assert podcast._episode_storage is episode_storage
assert hasattr(podcast, "_episode_storage")
assert not hasattr(podcast, "_episodes")
episodes = podcast.episodes
assert not hasattr(podcast, "_episode_storage")
assert hasattr(podcast, "_episodes")
assert episodes[0].guid == 1
assert episodes[0].title == 2
assert episodes[0].link == 3
assert episodes[0].media_href == 4
assert episodes[0].published == struct_time((2012, 5, 6, 7, 8, 9, 6, 127, -1))
assert episodes[0].downloaded == True
assert episodes[1].guid == 6
assert episodes[1].title == 7
assert episodes[1].link == 8
assert episodes[1].media_href == 9
assert episodes[1].published == struct_time((2012, 6, 7, 7, 8, 9, 3, 159, -1))
assert episodes[1].downloaded == False
assert not podcast.modified
assert not episodes.modified
assert not episodes[0].modified
assert not episodes[1].modified
episodes[0].guid = 11
assert not podcast.modified
assert episodes.modified
assert episodes[0].modified
assert not episodes[1].modified
episodes.modified = False
episodes[0].modified = False
assert not podcast.modified
assert not episodes.modified
assert not episodes[0].modified
assert not episodes[1].modified
assert len(episodes) == 2
episodes.append(Episode(podcast, 11, 12, 13, 14, "2012-12-12 12:12:12", True))
assert len(episodes) == 3
assert not podcast.modified
assert episodes.modified
assert not episodes[0].modified
assert not episodes[1].modified
assert not episodes[2].modified
开发者ID:matachi,项目名称:riley,代码行数:54,代码来源:models_test.py
注:本文中的time.struct_time函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论