Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

list comprehensions with dates

from datetime import datetime, timedelta
today = datetime.utcnow().date()
ct = datetime(today.year, today.month, today.day) # current_timestamp
time_intervals = []
while ct.hour <= 23 and today.day == ct.day:
  ct = ct + timedelta(minutes=10)
  time_intervals.append('%02d:%02d' % (ct.hour, ct.minute))
sorted_time_intervals = (sorted(time_intervals))
Source by stbtestautomation.wordpress.com #
 
PREVIOUS NEXT
Tagged: #list #comprehensions #dates
ADD COMMENT
Topic
Name
8+3 =