GithubHelp home page GithubHelp logo

Comments (4)

jhpratt avatar jhpratt commented on May 24, 2024 1

The error is correct. There is not sufficient information to parse a date, as only the last two digits of the year are known. As a result, it is ambiguous.

Side note: parsing also does not work if the weekday and month are in all caps

You need to explicitly permit case-insensitive matching. This is done with a case_sensitive:false in both weekday and month as indicated in the format description documentation.

from time.

GunnarMorrigan avatar GunnarMorrigan commented on May 24, 2024

Caused by these TryFrom impl for Date not considering year_last_two option.

In these lines:
https://github.com/time-rs/time/blob/bb397df38e5316d767ca3f3bd148e506b7af5587/time/src/parsing/parsed.rs#L758C1-L780C47

from time.

snspinn avatar snspinn commented on May 24, 2024

The source of confusion for me around the [year] component was due to the docs:

Note that when parsing, if only the last two digits of the year are present, the value returned may not be what was expected — if the return is successful at all (it's not guaranteed).

On first reading I interpreted this to mean that I could get back 1923 when I want 2023.
On second reading this sentence is ambiguous about whether parsing with repr:last_two is supported or not. Maybe this could be worded more clearly.

from time.

jhpratt avatar jhpratt commented on May 24, 2024

That description is a long-winded way of saying there are no guarantees. Either Ok or Err can be returned, and in the former it could use any century.

from time.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.