0% found this document useful (0 votes)
99 views1 page

Date and Time Manipulation Functions

This function takes in a value and tuple as arguments and returns a list with date, time, or datetime objects and/or strings depending on the value. For different values, it parses the tuple in various ways like strings or integers to create the date, time, or datetime and formats and returns them with additional strings in the list.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views1 page

Date and Time Manipulation Functions

This function takes in a value and tuple as arguments and returns a list with date, time, or datetime objects and/or strings depending on the value. For different values, it parses the tuple in various ways like strings or integers to create the date, time, or datetime and formats and returns them with additional strings in the list.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import calendar

import datetime

def dateandtime(val,tup):

l1=[]
s=””
if(val==1):
for x in tup:
s+=str(x)

d1 = [Link](s,’%Y%m%d’).date()
[Link](d1)
[Link]([Link](d1,’%d/%m/%Y’))
elif(val==2):
[Link]([Link](tup[0]))
elif(val==3):
s = “”
for x in tup:
s+=str(x)
s1=int(s)
t = [Link](tup[0],tup[1],tup[2])
[Link](t)
h=[Link](t,’%I’)

[Link](h)
elif(val==4):
for x in tup:
s+=str(x)
s1=int(s)
d1 = [Link](tup[0],tup[1],tup[2])
[Link](calendar.day_name[[Link]()])
[Link](calendar.month_name[[Link]])
[Link](str([Link](‘%j’)))
elif(val==5):
s=””
for x in tup:
s+=str(x)
s1=int(s)
[Link]([Link](s,’%Y%m%d%H%M%S’))
return l1

You might also like