Giter Site home page Giter Site logo

Support partial dates about lubridate HOT 4 CLOSED

tidyverse avatar tidyverse commented on June 19, 2024
Support partial dates

from lubridate.

Comments (4)

garrettgman avatar garrettgman commented on June 19, 2024

What would you want to be able to do with them? I think that might determine how we would implement this.

from lubridate.

vsbuffalo avatar vsbuffalo commented on June 19, 2024

I support this. I ran into this issue yesterday and it was incredibly frustrating. At the very least, lubridate should have graceful error messages. Consider:

> parse_date_time("April-2012", "%B-%Y")
Error in formats[[1]] : subscript out of bounds

Python's datetime library:

>>> from datetime import datetime
>>> datetime.strptime("April-2012", "%B-%Y")
datetime.datetime(2012, 4, 1, 0, 0)

Using the first date of a month is a good default behavior until NA date components can be added.

from lubridate.

vspinu avatar vspinu commented on June 19, 2024

First, this is a bug, and the helpful message were supposed to happen later. Second, it actually occurs because the underlying C implementation of stprptime doesn't parse partial dates of these sort. This is expectedly mentioned in the documentation of parse_date_time.

from lubridate.

vspinu avatar vspinu commented on June 19, 2024

New parser supports partial dates for numeric formats:

> parse_date_time(c("2/10","2/11"), "my")
[1] "2010-02-01 UTC" "2011-02-01 UTC"

Alphanumeric formats will unlikely be ever supported as it would require managing locales explicitly. Users can simply append 01 in front of truncated dates to overcome the issue.

from lubridate.

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.