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

Datetime becomes NA when calling "round_date" or "second" #217

Closed
stevencb opened this issue Dec 16, 2013 · 5 comments
Closed

Datetime becomes NA when calling "round_date" or "second" #217

stevencb opened this issue Dec 16, 2013 · 5 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@stevencb
Copy link

Machine: Mac Book Pro
Mac OS X: 10.8.5
Lubridate vers: lubridate_1.3.2

The issue:

Setting second(a_posixct_dt) = 60 causes the time to become NA under the circumstance discussed below. This does not occur on all versions / configurations (I didn't see this error on lubridate 1.2.0 using R 2.15.1 on a very old 17" MacBook Pro).

The bug originally appeared when calling "round_date" but this reproduces it as well.

  > library(lubridate)
  > sessionInfo()
  R version 3.0.2 (2013-09-25)
  Platform: x86_64-apple-darwin10.8.0 (64-bit)

  locale:
  [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

  attached base packages:
  [1] stats graphics grDevices utils datasets methods base

  other attached packages:
  [1] lubridate_1.3.2

  loaded via a namespace (and not attached):
  [1] digest_0.6.4 memoise_0.1 plyr_1.8 stringr_0.6.2
  > version
  _
  platform x86_64-apple-darwin10.8.0
  arch x86_64
  os darwin10.8.0
  system x86_64, darwin10.8.0
  status
  major 3
  minor 0.2
  year 2013
  month 09
  day 25
  svn rev 63987
  language R
  version.string R version 3.0.2 (2013-09-25)
  nickname Frisbee Sailing
  > at = ymd_hms('2013-12-01 23:59:59')
  > at
  [1] "2013-12-01 23:59:59 UTC"
  > second(at)
  [1] 59
  > second(at) = 60
  > at
  [1] NA
  >
  > at = ymd_hms('2013-12-01 23:59:59')
  > at
  [1] "2013-12-01 23:59:59 UTC"
  > second(at)
  [1] 59
  > second(at) = 61
  > at
  [1] "2013-12-02 00:00:01 UTC"


  Here is what fails when calling "round_date":

  > at = ymd_hms('2013-12-01 23:59:59.9999')
  > round_date(at, unit='second')
  [1] NA

@vspinu
Copy link
Member

vspinu commented Dec 14, 2014

This is ancient but it is still there.

 > at = ymd_hms('2013-12-01 23:59:59.9999')
  > round_date(at, unit='second')
  [1] NA

BTW, it seems that second is not working on a POSIX objects anymore. @garrettgman, did you remove POSIX accessors? What was the reason for that?

> second(ymd_hms('2013-12-01 23:59:59'))
Error in UseMethod("second") : 
  no applicable method for 'second' applied to an object of class "c('POSIXct', 'POSIXt')"
> year(ymd_hms('2013-12-01 23:59:59'))
Error in UseMethod("year") : 
  no applicable method for 'year' applied to an object of class "c('POSIXct', 'POSIXt')"

@vspinu vspinu added the bug an unexpected problem or unintended behavior label Dec 14, 2014
@stevencb
Copy link
Author

Thanks for picking this up. It would still be useful to have this fixed.

@kevinykuo
Copy link

@vspinu can you try reproducing the errors explicitly calling lubridate::second and lubridate::year?

@stevencb
Copy link
Author

I was wondering where things stand on this issue ?

Thanks.

@garrettgman
Copy link
Member

I just opened the other issue, which appears to be a duplicate. The quickest way to get a fix will be to submit a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants