# Path: firebase_admin/_rfc3339.py
# def parse_to_epoch(datestr):
# def _parse_to_datetime(datestr):


import pytest
from firebase_admin import _rfc3339


def test_epoch():
    expected = pytest.approx(0)
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00Z") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00z") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00+00:00") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00-00:00") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T01:00:00+01:00") == expected
    assert _rfc3339.parse_to_epoch("1969-12-31T23:00:00-01:00") == expected

def test_pre_epoch():
    expected = -5617641600
    assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00Z") == expected
    assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00+00:00") == expected
    assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00-00:00") == expected
    assert _rfc3339.parse_to_epoch("1791-12-26T01:00:00+01:00") == expected
    assert _rfc3339.parse_to_epoch("1791-12-25T23:00:00-01:00") == expected

def test_post_epoch():
    expected = 904892400
    assert _rfc3339.parse_to_epoch("1998-09-04T07:00:00Z") == expected
    assert _rfc3339.parse_to_epoch("1998-09-04T07:00:00+00:00") == expected
    assert _rfc3339.parse_to_epoch("1998-09-04T08:00:00+01:00") == expected
    assert _rfc3339.parse_to_epoch("1998-09-04T06:00:00-01:00") == expected

def test_micros_millis():
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00Z") == pytest.approx(0)
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.1Z") == pytest.approx(0.1)
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.001Z") == pytest.approx(0.001)

# Path: firebase_admin/_rfc3339.py
# def parse_to_epoch(datestr):
# def _parse_to_datetime(datestr):


# Path: tests/test_rfc3339.py
import pytest
from firebase_admin import _rfc3339



def test_epoch():
    expected = pytest.approx(0)
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00Z") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00z") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00+00:00") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00-00:00") == expected
    assert _rfc3339.parse_to_epoch("1970-01-01T01:00:00+01:00") == expected
    assert _rfc3339.parse_to_epoch("1969-12-31T23:00:00-01:00") == expected

def test_pre_epoch():
    expected = -5617641600
    assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00Z") == expected
    assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00+00:00") == expected
    assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00-00:00") == expected
    assert _rfc3339.parse_to_epoch("1791-12-26T01:00:00+01:00") == expected
    assert _rfc3339.parse_to_epoch("1791-12-25T23:00:00-01:00") == expected

def test_post_epoch():
    expected = 904892400
    assert _rfc3339.parse_to_epoch("1998-09-04T07:00:00Z") == expected
    assert _rfc3339.parse_to_epoch("1998-09-04T07:00:00+00:00") == expected
    assert _rfc3339.parse_to_epoch("1998-09-04T08:00:00+01:00") == expected
    assert _rfc3339.parse_to_epoch("1998-09-04T06:00:00-01:00") == expected

def test_micros_millis():
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00Z") == pytest.approx(0)
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.1Z") == pytest.approx(0.1)
    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.001Z") == pytest.approx(0.001)

    assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.000001Z") == pytest.approx(0.000001)