Comments (6)
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.
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.
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.
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.
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.
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)
- Cannot use both tz and useR=TRUE arguments
- Strange issue - anydate does not recognize format or ... ? HOT 3
- UK v US formats HOT 2
- Process only unique values for speed, please :) HOT 27
- Time is silently scrubbed when using certain string date time formats HOT 3
- Add argument for default MM/DD to add to just YYYY inputs HOT 1
- timedatectl problem on HPC? HOT 2
- Failed to activate service 'org.freedesktop.timedate1' on Google Cloud VM HOT 9
- month year specification HOT 7
- Could anydate support nanotime ? HOT 4
- Returning NA value HOT 3
- Feature requests: more flexibly find date substring in a non-date string; and process additional incomplete date substrings HOT 11
- European vs US date formats HOT 3
- Feature request: function to return which format was recognized. HOT 3
- Anytime errors with length 1 NA HOT 6
- Chinese date format suggestion HOT 3
- just yyyy-mm-dd hh:mm:ss but not AEST suffix HOT 5
- anytime() sometimes returns the wrong date HOT 2
- Inconsistent handling of vectors with unknown values HOT 1
- single digit dates with unambiguous month and year HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anytime.