# Python time.second() Examples

The following are 14 code examples for showing how to use time.second(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module , or try the search function .

Example 1
 Project: rpi_ai   Author: schollz   File: visual_cortex.py    License: MIT License 6 votes ```def saveImage():
keepDiskSpaceFree(config.diskSpaceToReserve)
time = datetime.datetime.now()
filenameFull = config.filepath + config.filenamePrefix + "-%04d%02d%02d%02d%02d%02d" % (time.year, time.month, time.day, time.hour, time.minute, time.second)+ "." + config.fileType

# save onto webserver
filename = "/var/www/temp.jpg"
subprocess.call("sudo raspistill -w "+ str(config.saveWidth) +" -h "+ str(config.saveHeight) + " -t 1 -n -vf -e " + config.fileType + " -q 15 -o %s" % filename, shell=True)
print "Captured image: %s" % filename

theSpeech = recognizeFace(filename,filenameFull)
if len(theSpeech)>2:
print theSpeech
saySomething(theSpeech,"en")
config.lookForFaces = 0

# Keep free space above given level ```
Example 2
 Project: JuicyRaspberryPie   Author: wensheng   File: minecraft_clock.py    License: BSD 2-Clause "Simplified" License 6 votes ```def updateTime(mc, clockCentre, lastTime, time):
#draw hour and minute hand
if (lastTime.minute != time.minute):
#clear hour hand
drawHourHand(mc, clockCentre, lastTime.hour, lastTime.minute, 'air')
#new hour hand
drawHourHand(mc, clockCentre, time.hour, time.minute, 'dirt')

#clear hand
drawMinuteHand(mc, clockCentre, lastTime.minute, 'air')
#new hand
drawMinuteHand(mc, clockCentre, time.minute, 'STONE')

#draw second hand
if (lastTime.second != time.second):
#clear hand
drawSecondHand(mc, clockCentre, lastTime.second, 'AIR')
#new hand
drawSecondHand(mc, clockCentre, time.second, 'WOOD_PLANKS') ```
Example 3
 Project: docassemble   Author: jhpyle   File: util.py    License: MIT License 6 votes ```def line_two(self, language=None):
"""Returns the second line of the address, including the city,
state and zip code."""
output = ""
#if hasattr(self, 'sublocality') and self.sublocality:
#    output += str(self.sublocality) + ", "
if hasattr(self, 'sublocality_level_1') and self.sublocality_level_1:
output += str(self.sublocality_level_1) + ", "
output += str(self.city)
if hasattr(self, 'state') and self.state:
output += ", " + str(self.state)
if hasattr(self, 'zip') and self.zip:
output += " " + str(self.zip)
elif hasattr(self, 'postal_code') and self.postal_code:
output += " " + str(self.postal_code)
return(output) ```
Example 4
 Project: graphene-django-extras   Author: eamigo86   File: date.py    License: MIT License 5 votes ```def _combine_date_time(d, t):
if (d is not None) and (t is not None):
return datetime(d.year, d.month, d.day, t.hour, t.minute, t.second)
return None ```
Example 5
 Project: piecewisecrf   Author: Vaan5   File: train.py    License: MIT License 5 votes ```def get_time_string():
'''

Returns current time in day_month_HH-MM-SS/ format

'''
time = datetime.now()
name = (str(time.day) + '_' + str(time.month) + '_%02d' % time.hour +
'-%02d' % time.minute + '-%02d' % time.second + '/')
return name ```
Example 6
 Project: JuicyRaspberryPie   Author: wensheng   File: minecraft_clock.py    License: BSD 2-Clause "Simplified" License 5 votes ```def drawClock(mc, clockCentre, radius, time):
drawCircle(mc, clockCentre.x, clockCentre.y, clockCentre.z, radius, 'DIAMOND_BLOCK')
drawHourHand(mc, clockCentre, time.hour, time.minute, 'DIRT')
drawMinuteHand(mc, clockCentre, time.minute, 'STONE')
drawSecondHand(mc, clockCentre, time.second, 'WOOD_PLANKS') ```
Example 7
 Project: crontabs   Author: robdmc   File: test_all.py    License: MIT License 5 votes ```def test_bad_every(self):
with self.assertRaises(ValueError):
Tab('a').every(second=1, minute=3)
# Cron().schedule(Tab('a').every(second=1, minute=3)) ```
Example 8
 Project: crontabs   Author: robdmc   File: test_all.py    License: MIT License 5 votes ```def test_base_case(self):
cron = Cron()
cron.schedule(
Tab('two_sec', verbose=False).every(seconds=2).run(time_logger, 'two_sec'),
Tab('three_sec', verbose=False).every(seconds=3).run(time_logger, 'three_sec')
)
with PrintCatcher(stream='stdout') as stdout_catcher:
cron.go(max_seconds=6)

base_lookup = {
'three_sec': 3,
'two_sec': 2,
}

lines = list(stdout_catcher.text.split('\n'))

# make sure times fall int right slots
for line in lines:
if line:
words = line.split()
name = words
time = parse('T'.join(words[1:]))
self.assertEqual(time.second % base_lookup[name], 0)

# make sure the tasks were run the proper number of times
counter = Counter()
for line in lines:
if line:
counter.update({line.split(): 1})

self.assertEqual(counter['two_sec'], 3)
self.assertEqual(counter['three_sec'], 2) ```
Example 9
 Project: suds   Author: suds-community   File: date.py    License: GNU Lesser General Public License v3.0 5 votes ```def _bump_up_time_by_microsecond(time):
"""
Helper function bumping up the given datetime.time by a microsecond,
cycling around silently to 00:00:00.0 in case of an overflow.

@param time: Time object.
@type time: B{datetime}.I{time}
@return: Time object.
@rtype: B{datetime}.I{time}

"""
dt = datetime.datetime(2000, 1, 1, time.hour, time.minute,
time.second, time.microsecond)
dt += datetime.timedelta(microseconds=1)
return dt.time() ```
Example 10
 Project: suds   Author: suds-community   File: date.py    License: GNU Lesser General Public License v3.0 5 votes ```def _time_from_match(match_object):
"""
Create a time object from a regular expression match.

Returns the time object and information whether the resulting time should
be bumped up by one microsecond due to microsecond rounding.

Subsecond information is rounded to microseconds due to a restriction in
the python datetime.datetime/time implementation.

The regular expression match is expected to be from _RE_DATETIME or
_RE_TIME.

@param match_object: The regular expression match.
@type match_object: B{re}.I{MatchObject}
@return: Time object + rounding flag.
@rtype: tuple of B{datetime}.I{time} and bool

"""
hour = int(match_object.group('hour'))
minute = int(match_object.group('minute'))
second = int(match_object.group('second'))
subsecond = match_object.group('subsecond')

round_up = False
microsecond = 0
if subsecond:
round_up = len(subsecond) > 6 and int(subsecond) >= 5
subsecond = subsecond[:6]
microsecond = int(subsecond + "0" * (6 - len(subsecond)))
return datetime.time(hour, minute, second, microsecond), round_up ```
Example 11
 Project: docassemble   Author: jhpyle   File: util.py    License: MIT License 5 votes ```def today(timezone=None, format=None):
"""Returns today's date at midnight as a DADateTime object."""
ensure_definition(timezone, format)
if timezone is None:
timezone = get_default_timezone()
val = pytz.utc.localize(datetime.datetime.utcnow()).astimezone(pytz.timezone(timezone))
if format is not None:
return dd(val.replace(hour=0, minute=0, second=0, microsecond=0)).format_date(format)
else:
return dd(val.replace(hour=0, minute=0, second=0, microsecond=0)) ```
Example 12
 Project: docassemble   Author: jhpyle   File: util.py    License: MIT License 5 votes ```def replace_time(self, time):
return self.replace(hour=time.hour, minute=time.minute, second=time.second, microsecond=time.microsecond) ```
Example 13
 Project: docassemble   Author: jhpyle   File: util.py    License: MIT License 5 votes ```def dd(obj):
 Project: docassemble   Author: jhpyle   File: util.py    License: MIT License 5 votes ```def dt(obj):
{"ft_lang_label":"__label__en","ft_lang_prob":0.5362045,"math_prob":0.71746093,"size":7597,"snap":"2021-04-2021-17","text_gpt3_token_len":1993,"char_repetition_ratio":0.14408007,"word_repetition_ratio":0.07918552,"special_character_ratio":0.26918522,"punctuation_ratio":0.25169608,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95776445,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-22T03:11:09Z\",\"WARC-Record-ID\":\"<urn:uuid:1ae20136-e3f6-42d1-8a0f-72caa6fc7157>\",\"Content-Length\":\"68020\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b98088e6-3b6e-4cab-b6d6-40b3fe53dc2c>\",\"WARC-Concurrent-To\":\"<urn:uuid:352473d6-a4b5-49d2-a540-c0bd33f55af7>\",\"WARC-IP-Address\":\"104.26.6.70\",\"WARC-Target-URI\":\"https://www.programcreek.com/python/example/5666/time.second\",\"WARC-Payload-Digest\":\"sha1:MLHVYWBIO3YK2JHI6R45B42VK54XASM3\",\"WARC-Block-Digest\":\"sha1:YLVEZOFOASWBFB7RAPXZSELI32WXCNB6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703529080.43_warc_CC-MAIN-20210122020254-20210122050254-00322.warc.gz\"}"}