Hide keyboard shortcuts

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* 

5 

6:Author: 

7 David Young 

8""" 

9import sys 

10import os 

11os.environ['TERM'] = 'vt100' 

12from fundamentals import tools 

13 

14 

15def get_now_datetime_filestamp(longTime=False): 

16 """ 

17 *A datetime stamp to be appended to the end of filenames: 'YYYYMMDDtHHMMSS'* 

18 

19 **Key Arguments** 

20 

21 - ``longTime`` -- make time string longer (more change of filenames being unique) 

22 

23 **Return** 

24 

25 - ``now`` -- current time and date in filename format 

26 

27 **Usage** 

28 

29 ```python 

30 from fundamentals.download import get_now_datetime_filestamp 

31 get_now_datetime_filestamp(longTime=False) 

32 #Out: '20160316t154635' 

33 

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

44 

45 return now