Skip to content

Parse error, ZonedDateTime #981

Description

@haf

This test fails:

let tzdb: IDateTimeZoneProvider =
  NodaTime.DateTimeZoneProviders.Tzdb

// ...
      testCase "parse failing zoned date time" <| fun _ ->
        let p = NodaTime.Text.ZonedDateTimePattern.ExtendedFormatOnlyIso.WithZoneProvider tzdb
        let res = p.Parse "1906-08-29T20:58:32 Etc/GMT-12 (+12)"

        if not res.Success then
          Tests.failtestf
            "Should successfully parse generated zoned date time, but got %s"
            res.Exception.Message

With this error message:

[20:43:33 ERR] serialisation/base types/parse failing zoned date time failed in 00:00:00.0350000.
Should successfully parse generated zoned date time, but got The value string does not match a simple character in the format string " ". Value being parsed: '1906-08-29T20:58:32 Etc/GMT-1^2 (+12)'. (^ indicates error position.)

The value was generated thus:

type Arbs =
  static member Instant () =
    let genInst = gen {
      let! y = Gen.choose(1900,2100)
      let! m = Gen.choose(1, 12)
      let! d = Gen.choose(1, System.DateTime.DaysInMonth(y, m))
      let! h = Gen.choose(0,23)
      let! min = Gen.choose(0,59)
      let! sec = Gen.choose(0,59)
      return Instant.FromUtc(y, m, d, h, min, sec)
    }
    Arb.fromGen genInst

  static member Timezone() =
    gen {
      let! tz = Gen.choose (0, tzdb.Ids.Count - 1)
      return tzdb.Item tzdb.Ids.[tz]
    }
    |> Arb.fromGen

  static member ZonedDateTime() =
    gen {
      let! tz = Arb.generate<_>
      let! inst = Arb.generate<_>
      return ZonedDateTime(inst, tz)
    }
    |> Arb.fromGen

Version of things:

macOS 10.12.6, mono 5.2.0.215, NodaTime 1.4

More failing test strings:

  • The value string does not match a simple character in the format string " ". Value being parsed: '1994-02-09T09:02:33 Etc/GMT-1^1 (+11)'. (^ indicates error position.)
  • ...

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions