# Path: riak/util.py
# def is_timeseries_supported(v=None):
#     if v is None:
#         v = sys.version_info
#     return v < (3,) or (v[:3] >= (3, 4, 4) and v[:3] != (3, 5, 0))
# 
# def datetime_from_unix_time_millis(ut):
#     if isinstance(ut, float):
#         raise ValueError('unix timestamp must not be a float, '
#                          'it must be total milliseconds since '
#                          'epoch as an integer')
#     utms = ut / 1000.0
#     return datetime.datetime.utcfromtimestamp(utms)
# 
# def unix_time_millis(dt):
#     if dt.tzinfo:
#         td = dt - epoch_tz
#     else:
#         td = dt - epoch
#     tdms = ((td.days * 24 * 3600) + td.seconds) * 1000
#     ms = td.microseconds // 1000
#     return tdms + ms


import datetime
import unittest
from riak.util import is_timeseries_supported, \
    datetime_from_unix_time_millis, \
    unix_time_millis
# Copyright 2010-present Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




class UtilUnitTests(unittest.TestCase):
    # NB:
    # 144379690 secs, 987 msecs past epoch
    # 144379690987 total msecs past epoch
    def test_conv_ms_timestamp_to_datetime_and_back(self):
        if is_timeseries_supported():
            # this is what would be stored in Riak TS
            v = 144379690987

# Path: riak/util.py
# def is_timeseries_supported(v=None):
#     if v is None:
#         v = sys.version_info
#     return v < (3,) or (v[:3] >= (3, 4, 4) and v[:3] != (3, 5, 0))
# 
# def datetime_from_unix_time_millis(ut):
#     if isinstance(ut, float):
#         raise ValueError('unix timestamp must not be a float, '
#                          'it must be total milliseconds since '
#                          'epoch as an integer')
#     utms = ut / 1000.0
#     return datetime.datetime.utcfromtimestamp(utms)
# 
# def unix_time_millis(dt):
#     if dt.tzinfo:
#         td = dt - epoch_tz
#     else:
#         td = dt - epoch
#     tdms = ((td.days * 24 * 3600) + td.seconds) * 1000
#     ms = td.microseconds // 1000
#     return tdms + ms


# Path: riak/tests/test_util.py
import datetime
import unittest
from riak.util import is_timeseries_supported, \
    datetime_from_unix_time_millis, \
    unix_time_millis

# Copyright 2010-present Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




class UtilUnitTests(unittest.TestCase):
    # NB:
    # 144379690 secs, 987 msecs past epoch
    # 144379690987 total msecs past epoch
    def test_conv_ms_timestamp_to_datetime_and_back(self):
        if is_timeseries_supported():
            # this is what would be stored in Riak TS
            v = 144379690987

            dt = datetime_from_unix_time_millis(v)