# 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
    )
    assert stamp.year == 2016
    assert stamp.month == 12
    assert stamp.day == 20
    assert stamp.hour == 21
    assert stamp.minute == 13
    assert stamp.second == 47
    assert stamp.microsecond == 123456
    assert stamp.nanosecond == 123456789


def test_ctor_w_micros_positional_and_nanos():
    with pytest.raises(TypeError):
        datetime_helpers.DatetimeWithNanoseconds(
            2016, 12, 20, 21, 13, 47, 123456, nanosecond=123456789
        )


def test_ctor_w_micros_keyword_and_nanos():
    with pytest.raises(TypeError):
        datetime_helpers.DatetimeWithNanoseconds(
            2016, 12, 20, 21, 13, 47, microsecond=123456, nanosecond=123456789
        )


def test_rfc3339_wo_nanos():
    stamp = datetime_helpers.DatetimeWithNanoseconds(2016, 12, 20, 21, 13, 47, 123456)
    assert stamp.rfc3339() == "2016-12-20T21:13:47.123456Z"



# 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

    )
    assert stamp.year == 2016
    assert stamp.month == 12
    assert stamp.day == 20
    assert stamp.hour == 21
    assert stamp.minute == 13
    assert stamp.second == 47
    assert stamp.microsecond == 123456
    assert stamp.nanosecond == 123456789


def test_ctor_w_micros_positional_and_nanos():
    with pytest.raises(TypeError):
        datetime_helpers.DatetimeWithNanoseconds(
            2016, 12, 20, 21, 13, 47, 123456, nanosecond=123456789
        )


def test_ctor_w_micros_keyword_and_nanos():
    with pytest.raises(TypeError):
        datetime_helpers.DatetimeWithNanoseconds(
            2016, 12, 20, 21, 13, 47, microsecond=123456, nanosecond=123456789
        )


def test_rfc3339_wo_nanos():
    stamp = datetime_helpers.DatetimeWithNanoseconds(2016, 12, 20, 21, 13, 47, 123456)
    assert stamp.rfc3339() == "2016-12-20T21:13:47.123456Z"



def test_rfc3339_wo_nanos_w_leading_zero():