Coder Social home page Coder Social logo

Comments (6)

eddelbuettel avatar eddelbuettel commented on May 13, 2024

Formating is done by format.POSIXct and is an R feature. Little we can do here, besides formatting ourselves which I'd rather not get into.

from anytime.

eddelbuettel avatar eddelbuettel commented on May 13, 2024

Demonstration not involving any code of this package:

R> txt <- c("2016-02-25 17:34:00.375",
+          "2016-02-25 17:34:00.376",
+          "2016-02-25 17:34:00.377")
R> pt <- as.POSIXct(txt)
R> pt
[1] "2016-02-25 17:34:00.375 CST"
[2] "2016-02-25 17:34:00.375 CST"
[3] "2016-02-25 17:34:00.377 CST"
R> 

My default is already options(digits.secs=6) which I didn't change. I'll close this as it really is an R issue. I don't like it either but that is the way it it, And even when using Boost to format, we get the same issue:

R> anytime:::testFormat("%Y-%m-%d %H:%M:%S%f", txt[1])
[1] "2016-02-25 17:34:00.375 CST"
R> anytime:::testFormat("%Y-%m-%d %H:%M:%S%f", txt[2])
[1] "2016-02-25 17:34:00.375 CST"
R> anytime:::testFormat("%Y-%m-%d %H:%M:%S%f", txt[3])
[1] "2016-02-25 17:34:00.377 CST"
R> 

from anytime.

eddelbuettel avatar eddelbuettel commented on May 13, 2024

Minor thinko on my part in the last bit. That isn't Boost formating the output. I may have a different helper for that or try one.

But the issue in this report is still with format.POSIXct() and hence an R issue.

from anytime.

eddelbuettel avatar eddelbuettel commented on May 13, 2024

But there is hope. I just added a format() function to Rcpp in the transition to the 'new' Datetime classes. Using that, we can do

options(width=50)
print(anytime:::format(pt))

which yields

edd@max:~/git/anytime(master)$ Rscript /tmp/formating.R 
[1] "2016-02-25 17:34:00.375000"
[2] "2016-02-25 17:34:00.376000"
[3] "2016-02-25 17:34:00.377000"
edd@max:~/git/anytime(master)$ 

I'll roll that out in anytime at some point -- I can't quite depend on that yet as not all Rcpp installations have it. And by the same token, I can probably take a shortcut and put a format() routine based on Boost in.

from anytime.

cactus74 avatar cactus74 commented on May 13, 2024

That this could have been a pure R issue did not even come to my mind. Great to hear this can be overcome in the near future using your format() routine. Thanks a lot.

from anytime.

eddelbuettel avatar eddelbuettel commented on May 13, 2024

It's messy. I just looked at it on the train -- where code comments by myself reminded me that I had looked into this. But in order to use Boost code for string formatting, we need the Boost timezone file which this package does not have :-/ RcppBDT so maybe we can suggest it.

Longer term the Rcpp-based solution will do.

from anytime.

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.