
from datetime import datetime
import time
"""Helper functions

Consists of functions to typically be used within templates, but also
available to Controllers. This module is available to templates as 'h'.
"""
# Import helpers as desired, or define your own, ie:
#from webhelpers.html.tags import checkbox, password
def importModuleFromFile(fullpath):
    """Loads  and returns module defined by the file path. Returns None if file could 
    not be loaded"""
    import os
    import sys
    import logging
    log = logging.getLogger(__name__)
    
    sys.path.append(os.path.dirname(fullpath))
    
    module = None
    try:
        module = __import__(os.path.splitext(os.path.basename(fullpath))[0])
 
    except Exception as ex:
        log.exception("Failed to load module:\n"+ex)
    finally:
        del sys.path[-1]
        return module

def convertToISO8601UTC (dateTimeArg=None):
    if isinstance(dateTimeArg, datetime) == True:
        return datetime.utcfromtimestamp(time.mktime(dateTimeArg.timetuple()))
    return dateTimeArg
        
def convertToISO8601Zformat(dateTimeArg=None):
    if isinstance(dateTimeArg, datetime) ==True:
        return convertToISO8601UTC (dateTimeArg).isoformat()+ "Z" 
    return dateTimeArg
    
def nowToISO8601Zformat():
    return convertToISO8601Zformat(datetime.now())

@@ -23,16 +23,27 @@
 datetime
+, timedelta
 %0Aimport 
@@ -891,32 +891,101 @@
 eTimeArg=None):%0A
+    %22%22%22This method assumes that the datetime is local naive time.%22%22%22%0A
     if isinstanc
@@ -1022,30 +1022,33 @@
 ue:%0A        
-return
+dateUTC =
  datetime.ut
@@ -1098,16 +1098,154 @@
 tuple())
+)
+%0A        #Add the macroseconds back since hte mktime conversion loses it%0A        return dataUTC + timedelta(0, 0, datetimeArg.microsecond
 )%0A    re
@@ -1536,11 +1536,27 @@
 ime.
+utc
 now()
-)
+.isoformat+%22Z%22
 %0A

Update the datatime helpers to deal with datetime with no timezone.