# Path: pytrainer/lib/date.py
# def getDateTime(time_):
#     # Time can be in multiple formats
#     # - zulu            2009-12-15T09:00Z
#     # - local ISO8601   2009-12-15T10:00+01:00
#     try:
#         dateTime = dateutil.parser.parse(time_)
#     except ValueError as e:
#         logging.debug("Unable to parse %s as a date time" % time_)
#         logging.debug(str(e))
#         return (None, None)
#     timezone = dateTime.tzinfo
#     if timezone is None: #got a naive time, so assume is local time
#         local_dateTime = dateTime.replace(tzinfo=tzlocal())
#     elif timezone == tzutc(): #got a zulu time
#         local_dateTime = dateTime.astimezone(tzlocal()) #datetime with localtime offset (from OS)
#     else:
#         local_dateTime = dateTime #use datetime as supplied
#     utc_dateTime = local_dateTime.astimezone(tzutc()) #datetime with 00:00 offset
#     return (utc_dateTime,local_dateTime)


import sys
import string
import math
import re
import os
import time
import logging
from datetime import datetime
from lxml import etree
from pytrainer.lib.date import getDateTime
                trackPointTagLast = mainNS.substitute(tag="trkpt[last()]")
                trackSegTag = mainNS.substitute(tag="trkseg")
                elevationTag = mainNS.substitute(tag="ele")
                nameTag = mainNS.substitute(tag="name")
                intensityTag = mainNS.substitute(tag="intensity")

            logging.debug("getting values...")
            self.Values = self._getValues()
        logging.debug("<<")

    def getMaxValues(self):
        return self.total_dist, self.total_time, self.maxvel, self.maxhr

    def getDate(self):
        return self.date

    def getTrackRoutes(self):
        trks = self.tree.findall(trackTag)
        tracks = []
        retorno = []
        for trk in trks:
            nameResult = trk.find(nameTag)
            if nameResult is not None:
                name = nameResult.text
            else:
                name = _("No Name")
            timeResult = trk.find(timeTag)
            if timeResult is not None:
                time_ = timeResult.text # check timezone
                logging.debug("TimeResult: %s" %time_)

# Path: pytrainer/lib/date.py
# def getDateTime(time_):
#     # Time can be in multiple formats
#     # - zulu            2009-12-15T09:00Z
#     # - local ISO8601   2009-12-15T10:00+01:00
#     try:
#         dateTime = dateutil.parser.parse(time_)
#     except ValueError as e:
#         logging.debug("Unable to parse %s as a date time" % time_)
#         logging.debug(str(e))
#         return (None, None)
#     timezone = dateTime.tzinfo
#     if timezone is None: #got a naive time, so assume is local time
#         local_dateTime = dateTime.replace(tzinfo=tzlocal())
#     elif timezone == tzutc(): #got a zulu time
#         local_dateTime = dateTime.astimezone(tzlocal()) #datetime with localtime offset (from OS)
#     else:
#         local_dateTime = dateTime #use datetime as supplied
#     utc_dateTime = local_dateTime.astimezone(tzutc()) #datetime with 00:00 offset
#     return (utc_dateTime,local_dateTime)


# Path: pytrainer/lib/gpx.py
import sys
import string
import math
import re
import os
import time
import logging
from datetime import datetime
from lxml import etree
from pytrainer.lib.date import getDateTime

                trackPointTagLast = mainNS.substitute(tag="trkpt[last()]")
                trackSegTag = mainNS.substitute(tag="trkseg")
                elevationTag = mainNS.substitute(tag="ele")
                nameTag = mainNS.substitute(tag="name")
                intensityTag = mainNS.substitute(tag="intensity")

            logging.debug("getting values...")
            self.Values = self._getValues()
        logging.debug("<<")

    def getMaxValues(self):
        return self.total_dist, self.total_time, self.maxvel, self.maxhr

    def getDate(self):
        return self.date

    def getTrackRoutes(self):
        trks = self.tree.findall(trackTag)
        tracks = []
        retorno = []
        for trk in trks:
            nameResult = trk.find(nameTag)
            if nameResult is not None:
                name = nameResult.text
            else:
                name = _("No Name")
            timeResult = trk.find(timeTag)
            if timeResult is not None:
                time_ = timeResult.text # check timezone
                logging.debug("TimeResult: %s" %time_)

                mk_time = getDateTime(time_)[0]