From 7f2f1ee91a61959a54223c87b7dd24c714a87c9b Mon Sep 17 00:00:00 2001 From: James Hollway Date: Sun, 1 Jun 2025 08:17:55 +0200 Subject: [PATCH 1/4] Updated rproj --- devmessydates.Rproj => dev_messydates.Rproj | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename devmessydates.Rproj => dev_messydates.Rproj (100%) diff --git a/devmessydates.Rproj b/dev_messydates.Rproj similarity index 100% rename from devmessydates.Rproj rename to dev_messydates.Rproj From 8eb96b0de69cff28b8a95f48c2265c690f8b1e9b Mon Sep 17 00:00:00 2001 From: James Hollway Date: Mon, 2 Jun 2025 15:27:58 +0200 Subject: [PATCH 2/4] Fixed how as_messydates() handles text in American format --- R/coerce_to_messydate.R | 6 ++++++ tests/testthat/test-coerce_to.R | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/R/coerce_to_messydate.R b/R/coerce_to_messydate.R index 3003b80d..7d059fcd 100644 --- a/R/coerce_to_messydate.R +++ b/R/coerce_to_messydate.R @@ -441,6 +441,12 @@ extract_from_text <- function(v) { # get ordinal and numeric dates spelled and replace in text out <- stri_squish(stringi::stri_replace_all_regex(v, "\\,|\\.|of | on | and|the | this| | day|year|month", " ")) + #reorder American dates + if(length(out)==1 && grepl("^[A-z]", out)){ + out <- paste(stringi::stri_split_fixed(out, " ")[[1]][c(2,1,3)], + collapse = " ") + } + for (k in seq_len(nrow(text_to_number))) { out <- gsub(paste0(text_to_number$text[k]), paste0(text_to_number$numeric[k]), diff --git a/tests/testthat/test-coerce_to.R b/tests/testthat/test-coerce_to.R index 0d37b39a..a748ae7e 100644 --- a/tests/testthat/test-coerce_to.R +++ b/tests/testthat/test-coerce_to.R @@ -5,7 +5,8 @@ test_that("Coercion from other date classes into messydt works", { character <- "2010-10-10" character2 <- "AD2010-10-10" character3 <- "{BC2010-10-10,BC2010-10-11,BC2010-10-12}" - month_text <- "10 October 2010" + dmy_text <- "10 October 2010" + mdy_text <- "October 10, 2010" messy <- as_messydate("2010-10-10") messyneg <- as_messydate("{-2010-10-10,-2010-10-11,-2010-10-12}") expect_equal(as_messydate(date), messy) @@ -14,14 +15,15 @@ test_that("Coercion from other date classes into messydt works", { expect_equal(as_messydate(character), messy) expect_equal(as_messydate(character2), messy) expect_equal(as_messydate(character3), messyneg) - expect_equal(as_messydate(month_text), messy) + expect_equal(as_messydate(dmy_text), messy) + expect_equal(as_messydate(mdy_text), messy) expect_equal(mdate(date), messy) expect_equal(mdate(POSIXct), messy) expect_equal(mdate(POSIXlt), messy) expect_equal(mdate(character), messy) expect_equal(mdate(character2), messy) expect_equal(mdate(character3), messyneg) - expect_equal(mdate(month_text), messy) + expect_equal(mdate(dmy_text), messy) }) test_that("Coercion of unespecified date components are properly handled", { From dff68cfff84e144e013d774bbf1d35d966276fb0 Mon Sep 17 00:00:00 2001 From: James Hollway Date: Mon, 2 Jun 2025 15:28:11 +0200 Subject: [PATCH 3/4] #patch bump --- DESCRIPTION | 4 ++-- NEWS.md | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1b887e65..896c8d0f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,8 +9,8 @@ Description: Contains a set of tools for constructing and coercing date ranges, and sets of dates. This is useful for describing and analysing temporal information, whether historical or recent, where date precision may vary. -Version: 0.5.3 -Date: 2025-03-18 +Version: 0.5.4 +Date: 2025-06-02 Authors@R: c(person(given = "James", family = "Hollway", diff --git a/NEWS.md b/NEWS.md index 76a1bcb6..600de701 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# messydates 0.5.4 + +## Coercion + +- Improved how `as_messydates()` handles text with dates in American format, +e.g. October 10, 2010 (fixes #86) + # messydates 0.5.3 ## Components From 781e40a59cfe3b09c3b180152f65a3808dfaf046 Mon Sep 17 00:00:00 2001 From: James Hollway Date: Mon, 2 Jun 2025 15:34:59 +0200 Subject: [PATCH 4/4] Fixed rproj ignore --- .Rbuildignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 7c2ab61d..024e9860 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,5 +1,4 @@ -^messydatesDev\.Rproj$ -^devmessydates\.Rproj$ +^dev_messydates\.Rproj$ ^\.Rproj\.user$ ^README\.Rmd$ ^LICENSE\.md$