Giter VIP home page Giter VIP logo

Comments (18)

hadley avatar hadley commented on July 20, 2024

In particular, this means that settors should retain the class of the original object.

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

major date time classes so far identified: Date, POSIXct, POSIXlt, timeDate, yearmon, yearqtr, zoo, timeSeries, ts, irts, fts, its, difftime

from lubridate.

hadley avatar hadley commented on July 20, 2024

Sounds like a good list.

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

note to self: perhaps create a is.date.object() to recognize all date formats (POSIXct, POSIXt, Date, etc.) then use as.POSIXct() to put them all into one format to operate on.

Will also have to add "+.Date" etc. to the top line

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

How should we handle this?

This code returns the same class for a settor
"second<-" <- function(x, value) {
date <- as.POSIXlt(x) - (second(x) - value)
f <- match.fun(paste("as", class(x), sep = "."))
f(date)
}

If the class does not support seconds, then "seconds<-"(x) just returns x. Do we prefer this? Or do we want to change x to a class that supports seconds (POSIXt)? Or do we want to make this an option with no change as the default?

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

Should ymd() recognize that 14448 is "2009-07-23" in Date format (i.e. class = "Date")?

from lubridate.

hadley avatar hadley commented on July 20, 2024

"second<-" <- function(x, value) UseMethod("second")
"second<-.default" <- function(x, value) as.POSIXlt(x) - (second(x) - value)

And no ymd() should not recognise 14448 as a date.

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for chron objects

I rewrote hour(x) so it returns the hour in the time zone that x is displayed in (otherwise, hour(x) would not equal the hour you see displayed on the screen for chron objects).

I made tz(x) return "GMT" for chron objects since chrons do not support timezones, but R treats them as if they have a timezone = "GMT" by default.

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for zoo objects

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for zooreg, yearmon, and yearqtr objects

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for timeDate objects

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for xts objects

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for its objects

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

difftime is not a date time object

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work as much as I think they're going to with ti objects from the tis package. That package shares the same function names as ours. Also, in its documentation it states the things it tries to do don't always work (see hms() documentation).

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for timeSeries objects

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

accessors now work for fts objects

from lubridate.

garrettgman avatar garrettgman commented on July 20, 2024

ts objects do not use a recognized date format. I'm not sure if I should write code to decipher them. Or if there would be any point, because if users want that sort of specificity they should use one of the above classes and not a ts class.

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.