blob: 098c576d6b5a844f4b2f9f0e1114f3010848d10c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# Copyright 2008 Nanorex, Inc. See LICENSE file for details.
"""
utilities/TimeUtilities.py Stuff related to processing time values.
Not called utilities/time.py because of the python time package.
@author: EricM
@version: $Id$
@copyright: 2008 Nanorex, Inc. See LICENSE file for details.
"""
from datetime import datetime
def timeStamp(when = None):
"""
Return a string suitable for use as a timestamp component of a
filename. You can pass in a datetime object to extract the time
from, or pass nothing and the string will represent now.
"""
if (when is None):
when = datetime.now()
stamp = "%04d-%02d-%02d-%02d-%02d-%02d" % (when.year,
when.month,
when.day,
when.hour,
when.minute,
when.second)
return stamp
|