Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add format to Anytime() #127

Closed
pollytatouin opened this issue May 2, 2023 · 3 comments
Closed

Add format to Anytime() #127

pollytatouin opened this issue May 2, 2023 · 3 comments
Assignees
Labels
enhancement Feature request
Milestone

Comments

@pollytatouin
Copy link

Hi,

First of all, thank you for this incredibly useful package.

I had issues with some dates from a report returning as NA, and I traced it down to anytime() needing some additional formats in order to properly read the format used by salesforce (at least in my dataset). There is ambiguity.

I don't know if it's common to all salesforce datetime fields, but perhaps it's worth an adjustment if so ?

require(anytime)

date1 <- "07/12/2022 12:00 PM"
date2 <- "24/02/2022 12:00 PM"

anytime(date1, tz = "UTC", asUTC = T)
#> [1] "2022-07-12 UTC"
anytime(date2, tz = "UTC", asUTC = T)
#> [1] NA

addFormats("%d-%m-%Y %H:%M")
anytime(date2, tz = "UTC", asUTC = T)
#> [1] "2022-02-24 12:00:00 UTC"

Created on 2023-05-02 by the reprex package (v2.0.1)

@StevenMMortimer
Copy link
Owner

Thanks for flagging. Sorry for the delay in responding. If you add that function call addFormats("%d-%m-%Y %H:%M") at the top of your R script, then the {{salesforcer}} functions should acknowledge and use it. Have you tried that?

I'm having trouble figuring out where to slot that option into the function arguments or package arguments and how to document since it's very specific to the type of data you're pulling. I think most include a full date or timestamp, not rounded to the nearest hour and minute.

@StevenMMortimer StevenMMortimer added the enhancement Feature request label Nov 4, 2024
@StevenMMortimer
Copy link
Owner

In 76ede6a, I've added some code that will automatically register "%m-%d-%Y %H:%M" and "%d-%m-%Y %H:%M" as formats upon package load. If I find there are other common variants that show up across organizations, then I can add them in the same location. Testing this commit now.

@StevenMMortimer
Copy link
Owner

Closing. This enhancement was included in v1.0.2 which was accepted by CRAN on Nov 6.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement Feature request
Projects
None yet
Development

No branches or pull requests

2 participants