<jupyter_start><jupyter_text>Date and TimeDate and time manipulation is provided by a built-in Python module datetime. This chapter assumes that datetime has been imported using import datetime as dt.<jupyter_code>from __future__ import print_function, division
import datetime as dt

yy, mm, dd = 2014, 3, 8
d = dt.date(yy, mm, dd)
print(d)
h, m, s, ms = 12, 26, 36, 10
t = dt.time(h, m, s, ms)
print(t)
d1 = dt.datetime(yy, mm, dd, h, m, s, ms)
print(d1)
d2 = dt.datetime(yy+1, mm, dd, h, m, s, ms)
print(d2)
print(d2 - d1)
d3 = d2 + dt.timedelta(30, 0, 0)
print(d2, d3)
d4 = dt.datetime(2014, 3, 8) + dt.timedelta(30, 12, 0)
print(d4)
from datetime import date
d = date.today()
yy, mm, dd = d.year, d.month, d.day
print dd, mm, yy

from datetime import date, time, timedelta
start = dt.date(2015,2,9)
end = dt.date(2015,6,1)
print(start)
print(end)
print(end - start)
d = timedelta(days=7)
print(start+d)
csrc512 = [(1, time(9,0,0)), (2, time(8,0,0)), (3, time(8,0,0)), (4,time(11,15,0))]
csrc512_date = []
print(csrc512)
from datetime import *
from dateutil.relativedelta import *

def get_working_days(s1, s2, c, holidays):
    d = []
    while s1 <= s2:
        for x in c:
            ss = s1 + relativedelta(weekday=x)
            if ss <= s2:
                if ss not in holidays:
                    d.append(ss)
                    print(ss, end="   ")
            else:
                break
        s1 = s1 + relativedelta(days=7)
        print()
    return d

s1 = date(2015,2,9)
s2 = date(2015,6,1)
print('From:', s1, 'to:', s2)
print()

holidays = [date(2015,2,17), date(2015,3,21), date(2015,3,23), date(2015,3,24), date(2015,3,25)]
holidays += [date(2015,4,2), date(2015,4,3), date(2015,4,4), date(2015,4,14), date(2015,4,21)]
holidays += [date(2015,5,1), date(2015,5,14), date(2015,5,15), date(2015,5,16)]

csrc512 = [TU, WE, TH, FR]
d = get_working_days(s1, s2, csrc512, holidays)
print(len(d))
print(d)
print(date(2015,2,9) + relativedelta(weekday=MO(-1)))
csre503 = [TU, TH, FR, SA]
d = get_working_days(s1, s2, csre503, holidays)
print(len(d))
print(d)
import time

ticks = time.time()
print("Ticks since 12:00am Jan 1, 1970:", ticks)
localtime = time.localtime()
print(type(localtime), "Local time:", localtime)
localtime = time.asctime(time.localtime(time.time()))
print("Localtime:", localtime)
import calendar

cal = calendar.month(2015, 2)
print(cal)
print(time.asctime(time.localtime(time.time())))
print(calendar.isleap(2014))
print(calendar.isleap(2016))
print(calendar.weekday(2015,2,15))<jupyter_output>6
{'fraction_non_alphanumeric': 0.17415287628053586, 'fraction_numerical': 0.10007880220646179, 'mean_word_length': 4.1396761133603235, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '316155', 'license': 'CC0-1.0', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1034, 'n_words': 262, 'path': 'Date Time.ipynb', 'repo_name': 'satish-annigeri/Notebooks', 'size': '2538'}