fund-indicators/Functions.py

25 lines
708 B
Python
Raw Permalink Normal View History

2019-01-16 08:54:06 -08:00
# Python file for general functions
class Functions:
def getNearest(items, pivot):
return min(items, key=lambda x: abs(x - pivot))
def stringToDate(date):
from datetime import datetime
2019-01-17 08:50:19 -08:00
2019-01-16 08:54:06 -08:00
#datetime_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p')
datetime_object = datetime.strptime(date, '%Y-%m-%d').date()
return(datetime_object)
2019-01-17 08:50:19 -08:00
'''
dateSplit = date.split('-')
year = int(dateSplit[0])
month = int(dateSplit[1])
day = int(dateSplit[2])
datetime_object = datetime.date(year, month, day)
'''
return datetime_object
2019-01-16 08:54:06 -08:00
def main():
exit()
if __name__ == "__main__":
main()