Search
 
SCRIPT & CODE EXAMPLE
 

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))
Comment

PREVIOUS NEXT
Code Example
Python :: ---Input Chevy Times--- 
Python :: pythongalaxy.com 
Python :: converting 4hr 20min to minutes 
Python :: medium how to interact with jupyter 
Python :: what takes more memory string or list python 
Python :: gdal user with anaconda 
Python :: python amino acid dictionary 
Python :: Rewrite the equation shown in Figure 2.4 as a Python expression and get the result of the equation: Pay special attention to the order of operations. 
Python :: bar chart with x-ticks 
Python :: python resample time series 
Python :: left rotation in list 
Python :: frogenset ito dataframe pandas 
Python :: python fibonacci sequence while loop 
Python :: when was python 3 released 
Python :: left-align the y-tick labels | remove the current labels 
Python :: RuntimeError: cuda runtime error (711) : peer mapping resources exhausted at /pytorch/aten/src/THC/THCGeneral.cpp:139 
Python :: list all subdirectories up to a level 
Python :: how fast is iglob 
Python :: find average of list via for loop python 
Python :: module level import not at top of file 
Python :: UTC to ISO 8601 with Local TimeZone information without microsecond (Python 3): 
Python :: accumulate sum of elements in list 
Python :: read(stdin, buf) ctf 
Python :: str vs rper in python 
Python :: extended slices [::2] 
Python :: zip list python first element 
Python :: pip install time python 
Python :: Python return statement (Write and Call Function) 
Python :: stop level of the broker 
Python :: selenium emojis 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =