9 examples of 'get hour from datetime python' in Python

Every line of 'get hour from datetime python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
143def hoursLater(date, h):
144 return date + + timedelta(hours=h)

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

3def hour_to_time(hour):
4 return "%2i:%02i" % (math.floor(hour), (hour - math.floor(hour)) * 60)
216def float_hour(self):
217 """Get hour and minute as a float value, e.g. 6.25 for 6:15."""
218 return self.hour + self.minute / 60.0
342def hour(self, column=None, keep=False):
343 return self._generic(name='_hour', column=column, keep=keep, multiple=True)
657def setTime(date, hour, minute, second):
658 """Takes in a date, and returns a copy of it with the time fields
659 set as specified.
661 Args:
662 date (datetime): The starting date.
663 hour (int): The hours (0-23) to set.
664 minute(int): The minutes (0-59) to set.
665 second (int): The seconds (0-59) to set.
667 Returns:
668 datetime: A new date, set to the appropriate time.
669 """
670 return date.replace(hour=hour, minute=minute, second=second, microsecond=0)
72def setHour(self, hour):
73 self.calendar = datetime(self.calendar.year, self.calendar.month, self.calendar.day, hour, self.calendar.minute, self.calendar.second, self.calendar.microsecond, self.calendar.tzinfo)
74def test_get_hour(self):
75 self.assertEqual(
76 meterbus.DateCalculator.getHour(255),
77 31,
78 )
26def strHoursToTimeDelta(hoursAsString):
27 return dt.timedelta(hours=int(hoursAsString))
28def get_alarm_hour(alarm_time):
29 if alarm_time.hour == 1: # word correction
30 alarm_hour = "ein"
31 else:
32 alarm_hour = alarm_time.hour
33 return alarm_hour

Related snippets