Coverage for fundamentals/download/get_now_datetime_filestamp.py : 0%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/local/bin/python
2# encoding: utf-8
3"""
4*Generate the datetime stamp for filenames*
6:Author:
7 David Young
8"""
9import sys
10import os
11os.environ['TERM'] = 'vt100'
12from fundamentals import tools
15def get_now_datetime_filestamp(longTime=False):
16 """
17 *A datetime stamp to be appended to the end of filenames: 'YYYYMMDDtHHMMSS'*
19 **Key Arguments**
21 - ``longTime`` -- make time string longer (more change of filenames being unique)
23 **Return**
25 - ``now`` -- current time and date in filename format
27 **Usage**
29 ```python
30 from fundamentals.download import get_now_datetime_filestamp
31 get_now_datetime_filestamp(longTime=False)
32 #Out: '20160316t154635'
34 get_now_datetime_filestamp(longTime=True)
35 #Out: '20160316t154644133638'
36 ```
37 """
38 from datetime import datetime, date, time
39 now = datetime.now()
40 if longTime:
41 now = now.strftime("%Y%m%dt%H%M%S%f")
42 else:
43 now = now.strftime("%Y%m%dt%H%M%S")
45 return now