# Path: proto/datetime_helpers.py
# _UTC_EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=datetime.timezone.utc)
# _RFC3339_MICROS = "%Y-%m-%dT%H:%M:%S.%fZ"
# _RFC3339_NO_FRACTION = "%Y-%m-%dT%H:%M:%S"
# _RFC3339_NANOS = re.compile(
#     r"""
#     (?P<no_fraction>
#         \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}  # YYYY-MM-DDTHH:MM:SS
#     )
#     (                                        # Optional decimal part
#      \.                                      # decimal point
#      (?P<nanos>\d{1,9})                      # nanoseconds, maybe truncated
#     )?
#     Z                                        # Zulu
# """,
#     re.VERBOSE,
# )
# def _from_microseconds(value):
# def _to_rfc3339(value, ignore_zone=True):
#     def __new__(cls, *args, **kw):
#     def replace(self, *args, **kw):
#     def nanosecond(self):
#     def rfc3339(self):
#     def from_rfc3339(cls, stamp):
#     def timestamp_pb(self):
#     def from_timestamp_pb(cls, stamp):
# class DatetimeWithNanoseconds(datetime.datetime):


import calendar
import datetime
import pytest
import pytz
from proto import datetime_helpers
from google.protobuf import timestamp_pb2
# See the License for the specific language governing permissions and
# limitations under the License.





ONE_MINUTE_IN_MICROSECONDS = 60 * 1e6


def test_from_microseconds():
    five_mins_from_epoch_in_microseconds = 5 * ONE_MINUTE_IN_MICROSECONDS
    five_mins_from_epoch_datetime = datetime.datetime(
        1970, 1, 1, 0, 5, 0, tzinfo=datetime.timezone.utc
    )

    result = datetime_helpers._from_microseconds(five_mins_from_epoch_in_microseconds)

    assert result == five_mins_from_epoch_datetime


def test_to_rfc3339():
    value = datetime.datetime(2016, 4, 5, 13, 30, 0)
    expected = "2016-04-05T13:30:00.000000Z"
    assert datetime_helpers._to_rfc3339(value) == expected


def test_to_rfc3339_with_utc():
    value = datetime.datetime(2016, 4, 5, 13, 30, 0, tzinfo=datetime.timezone.utc)
    expected = "2016-04-05T13:30:00.000000Z"

# Path: proto/datetime_helpers.py
# _UTC_EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=datetime.timezone.utc)
# _RFC3339_MICROS = "%Y-%m-%dT%H:%M:%S.%fZ"
# _RFC3339_NO_FRACTION = "%Y-%m-%dT%H:%M:%S"
# _RFC3339_NANOS = re.compile(
#     r"""
#     (?P<no_fraction>
#         \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}  # YYYY-MM-DDTHH:MM:SS
#     )
#     (                                        # Optional decimal part
#      \.                                      # decimal point
#      (?P<nanos>\d{1,9})                      # nanoseconds, maybe truncated
#     )?
#     Z                                        # Zulu
# """,
#     re.VERBOSE,
# )
# def _from_microseconds(value):
# def _to_rfc3339(value, ignore_zone=True):
#     def __new__(cls, *args, **kw):
#     def replace(self, *args, **kw):
#     def nanosecond(self):
#     def rfc3339(self):
#     def from_rfc3339(cls, stamp):
#     def timestamp_pb(self):
#     def from_timestamp_pb(cls, stamp):
# class DatetimeWithNanoseconds(datetime.datetime):


# Path: tests/test_datetime_helpers.py
import calendar
import datetime
import pytest
import pytz
from proto import datetime_helpers
from google.protobuf import timestamp_pb2

# See the License for the specific language governing permissions and
# limitations under the License.





ONE_MINUTE_IN_MICROSECONDS = 60 * 1e6


def test_from_microseconds():
    five_mins_from_epoch_in_microseconds = 5 * ONE_MINUTE_IN_MICROSECONDS
    five_mins_from_epoch_datetime = datetime.datetime(
        1970, 1, 1, 0, 5, 0, tzinfo=datetime.timezone.utc
    )

    result = datetime_helpers._from_microseconds(five_mins_from_epoch_in_microseconds)

    assert result == five_mins_from_epoch_datetime


def test_to_rfc3339():
    value = datetime.datetime(2016, 4, 5, 13, 30, 0)
    expected = "2016-04-05T13:30:00.000000Z"
    assert datetime_helpers._to_rfc3339(value) == expected


def test_to_rfc3339_with_utc():
    value = datetime.datetime(2016, 4, 5, 13, 30, 0, tzinfo=datetime.timezone.utc)
    expected = "2016-04-05T13:30:00.000000Z"

    assert datetime_helpers._to_rfc3339(value, ignore_zone=False) == expected