[Mumps2Py:] [93] added support for translating $HOROLOG |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 93
Author: pgallot
Date: 2008-02-12 03:21:18 +0000 (Tue, 12 Feb 2008)
Log Message:
-----------
added support for translating $HOROLOG
Modified Paths:
--------------
trunk/mumps2py/mumpsCL.py
Modified: trunk/mumps2py/mumpsCL.py
===================================================================
--- trunk/mumps2py/mumpsCL.py 2008-02-12 00:14:55 UTC (rev 92)
+++ trunk/mumps2py/mumpsCL.py 2008-02-12 03:21:18 UTC (rev 93)
@@ -17,16 +17,33 @@
"""Compatibility Library to allow Mumps source code translated to Python"""
from types import *
+import datetime
#TODO: first order of business, an iterator to use when translating
# Mumps for-command. Unlike range, a Mumps iteration includes the terminal
# value. F i:1:1:10 iterates from 1 to 10, inclusive. the equivalent would be
# range(1, 11)
+def Mf_horolog(timestamp = None):
+ """function that emulates Mumps $Horolog variable."""
+ if timestamp == None:
+ now = datetime.datetime.utcnow()
+ else:
+ now = timestamp
+
+ mumps_epoch = datetime.date(1840, 12, 31)
+ date_delta = now.date() - mumps_epoch
+
+ midnightpast = now.replace(hour = 0, minute = 0, second = 0,
+ microsecond = 0)
+ time_delta = now - midnightpast
+
+ horolog = "%05d,%05d" % (date_delta.days, time_delta.seconds)
+ return horolog
+
def Mf_data(loc_adr_space, name, indices_tuple = None):
"""Python-equivalent of the Mumps $Data intrinsic
NOTE: not yet designed to work with Mumps Global variables."""
-
val = 0
if loc_adr_space.has_key(name):
the_var = loc_adr_space[name]
@@ -60,7 +77,6 @@
def Mc_merge(recipient, recipient_modifier, copy_item, copy_item_subset):
"""merge a subset of one dictionary into a subset of another"""
-
new_keys = {}
if copy_item_subset != (None,):
len_subset = len(copy_item_subset)