Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone parsing issues #10

Open
bbrauns opened this issue Jun 24, 2021 · 0 comments
Open

Timezone parsing issues #10

bbrauns opened this issue Jun 24, 2021 · 0 comments

Comments

@bbrauns
Copy link

bbrauns commented Jun 24, 2021

Hi! Thank you for providing this awesome implementation!

There seems to be a datetime related issue if I run for example the unit test EncodeDecode_WrongPublicKey which throws the error

System.FormatException: The UTC representation of the date '0001-01-01' falls outside the year range 1-9999.
...

Explicitly adding datetime values for SampleTakenDate and VaccinationDate in CreateCWTTestData() seems to fix that:

 var d = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second, DateTimeKind.Unspecified);
            var o = new DateTimeOffset(d, TimeSpan.FromHours(0));
            var tests = new List<TestEntry>
            {
                new()
                {
                    CountryOfTest = "IS",
                    NAATTestName = "PCR Covid-19",
                    SampleTakenDate = o
                }
            };

            var d1 = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 0,0,0, DateTimeKind.Unspecified);
            var o1 = new DateTimeOffset(d1, TimeSpan.FromHours(0));
            var vacs = new List<VaccinationEntry>
            {
                new()
                {
                    Issuer = "Test Issuer",
                    VaccinationDate = o1
                }
            };

But afterwards the JToken.DeepEquals fails because of differences regarding timezones of the property VaccinationDate. See the following json serializations:

cwtToTest.DGCv1:

{
    "DateOfBirthString": "2000-01-01",
    "DateOfBirth": "2000-01-01T00:00:00",
    "Name": {
        "SurnameName": "Testson",
        "SurameTransliterated": null,
        "GivenName": "Test",
        "GivenNameTraslitaerated": null
    },
    "Recovery": null,
    "Test": [{
            "CertificateIdentifier": null,
            "CountryOfTest": "IS",
            "Issuer": null,
            "RATTestDeviceIdentifier": null,
            "NAATTestName": "PCR Covid-19",
            "SampleTakenDate": "2021-06-24T07:35:46+00:00",
            "TestingCenter": null,
            "Disease": null,
            "TestResult": null,
            "TestType": null
        }
    ],
    "Vaccination": [{
            "CertificateIdentifier": null,
            "CountryOfVaccination": null,
            "DoseNumber": 0,
            "VaccinationDate": "2021-06-24T00:00:00+00:00",
            "Issuer": "Test Issuer",
            "Manufacturer": null,
            "MedicalProduct": null,
            "TotalDoses": 0,
            "Disease": null,
            "Vaccine": null
        }
    ],
    "Version": null
}

cwt.DGCv1:

{
    "DateOfBirthString": "2000-01-01",
    "DateOfBirth": "2000-01-01T00:00:00",
    "Name": {
        "SurnameName": "Testson",
        "SurameTransliterated": null,
        "GivenName": "Test",
        "GivenNameTraslitaerated": null
    },
    "Recovery": null,
    "Test": [{
            "CertificateIdentifier": null,
            "CountryOfTest": "IS",
            "Issuer": null,
            "RATTestDeviceIdentifier": null,
            "NAATTestName": "PCR Covid-19",
            "SampleTakenDate": "2021-06-24T07:35:46+00:00",
            "TestingCenter": null,
            "Disease": null,
            "TestResult": null,
            "TestType": null
        }
    ],
    "Vaccination": [{
            "CertificateIdentifier": null,
            "CountryOfVaccination": null,
            "DoseNumber": 0,
            "VaccinationDate": "2021-06-24T00:00:00+02:00",
            "Issuer": "Test Issuer",
            "Manufacturer": null,
            "MedicalProduct": null,
            "TotalDoses": 0,
            "Disease": null,
            "Vaccine": null
        }
    ],
    "Version": null
}

Or is there something I am missing which I have to configure accordingly? My PCs timezone: UTC +2 CEST Central European Summer Time Berlin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant