equal
deleted
inserted
replaced
22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 |
25 |
26 from __future__ import absolute_import |
26 from __future__ import absolute_import |
|
27 from __future__ import division |
27 import datetime |
28 import datetime |
28 |
29 |
29 |
30 |
30 # ------------------------------------------------------------------------------- |
31 # ------------------------------------------------------------------------------- |
31 # Date and Time conversion function |
32 # Date and Time conversion function |
74 # if no greater non-null values are available. This variable is used to |
75 # if no greater non-null values are available. This variable is used to |
75 # inhibit formatting until a non-null value is found |
76 # inhibit formatting until a non-null value is found |
76 not_null = False |
77 not_null = False |
77 |
78 |
78 for val, format in [ |
79 for val, format in [ |
79 (int(microseconds) / DAY, "%dd"), # Days |
80 (int(microseconds) // DAY, "%dd"), # Days |
80 ((int(microseconds) % DAY) / HOUR, "%dh"), # Hours |
81 ((int(microseconds) % DAY) // HOUR, "%dh"), # Hours |
81 ((int(microseconds) % HOUR) / MINUTE, "%dm"), # Minutes |
82 ((int(microseconds) % HOUR) // MINUTE, "%dm"), # Minutes |
82 ((int(microseconds) % MINUTE) / SECOND, "%ds")]: # Seconds |
83 ((int(microseconds) % MINUTE) // SECOND, "%ds")]: # Seconds |
83 |
84 |
84 # Add value to TIME literal if value is non-null or another non-null |
85 # Add value to TIME literal if value is non-null or another non-null |
85 # value have already be found |
86 # value have already be found |
86 if val > 0 or not_null: |
87 if val > 0 or not_null: |
87 data += format % val |
88 data += format % val |
126 |
127 |
127 # TIME_OF_DAY literal prefix |
128 # TIME_OF_DAY literal prefix |
128 data = "TOD#" |
129 data = "TOD#" |
129 |
130 |
130 for val, format in [ |
131 for val, format in [ |
131 (int(microseconds) / HOUR, "%2.2d:"), # Hours |
132 (int(microseconds) // HOUR, "%2.2d:"), # Hours |
132 ((int(microseconds) % HOUR) / MINUTE, "%2.2d:"), # Minutes |
133 ((int(microseconds) % HOUR) // MINUTE, "%2.2d:"), # Minutes |
133 ((int(microseconds) % MINUTE) / SECOND, "%2.2d."), # Seconds |
134 ((int(microseconds) % MINUTE) // SECOND, "%2.2d."), # Seconds |
134 (microseconds % SECOND, "%6.6d")]: # Microseconds |
135 (microseconds % SECOND, "%6.6d")]: # Microseconds |
135 |
136 |
136 # Add value to TIME_OF_DAY literal |
137 # Add value to TIME_OF_DAY literal |
137 data += format % val |
138 data += format % val |
138 |
139 |