Exemplo n.º 1
0
def is_nat(value):
    """
    Checks if the given value is NaT.
    """
    if EnvironmentHelper.is_tslib_available():
        return value is NaT
    else:
        return False
Exemplo n.º 2
0
def serialize(object_value):
    if EnvironmentHelper.is_tslib_available(
    ) and type(object_value) is EnvironmentHelper.Timestamp:
        object_value = object_value.to_pydatetime()
    # format: yyyy-mm-dd HH:MM:SS (+microseconds and offset to UTC if available)
    datestr = object_value.isoformat(' ')
    # Add timezone name (offset already included in isoformat)
    if object_value.tzname():
        datestr += '[' + object_value.tzname() + ']'
    # Find +/- sign of timezone offset
    tzidx = max(datestr.find('+'), datestr.find('-', 10))
    if tzidx < 0:
        tzidx = len(datestr)
    # If microseconds available cut down to millis otherwise add millis
    if object_value.microsecond > 0:
        datestr = datestr[:tzidx - 3] + datestr[tzidx:]
    else:
        datestr = datestr[:tzidx] + '.000' + datestr[tzidx:]
    return datestr.encode('utf-8')
Exemplo n.º 3
0
"""
@author Clemens von Schwerin, KNIME GmbH, Konstanz, Germany
@author Patrick Winter, KNIME GmbH, Konstanz, Germany
@author Marcel Wiedenmann, KNIME GmbH, Konstanz, Germany
@author Christian Dietz, KNIME GmbH, Konstanz, Germany
"""

# This should be the first statement in each module that makes specific demands on the Python environment.
import EnvironmentHelper

if EnvironmentHelper.is_python3():
    import importlib
else:
    import imp

if EnvironmentHelper.is_tslib_available():
    from EnvironmentHelper import Timestamp
    from EnvironmentHelper import NaT
else:
    Timestamp = None
    NaT = None

import base64
import inspect
import math
import numpy
import os

from datetime import datetime

# list of equivalent types