From 69c1fe85e519670ec237c3668d64b907bc74f9fe Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 23 Oct 2016 08:59:39 -0500 Subject: [PATCH] additional RFC822-style format (closes #21) --- ChangeLog | 7 ++++++- DESCRIPTION | 4 ++-- src/anytime.cpp | 3 +++ tests/allFormats.R | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f7c282..b3a722e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-10-23 Dirk Eddelbuettel + + * src/anytime.cpp (sformats[]): New format for RFC 822 style date + * tests/allFormats.R: New test + 2016-10-22 Dirk Eddelbuettel * NAMESPACE: Adding utctime() and utcdate() to export() @@ -54,7 +59,7 @@ 2016-10-14 Dirk Eddelbuettel - * src/anytime.cpp (sformats[]]): Add several new date(time) formats + * src/anytime.cpp (sformats[]): Add several new date(time) formats of the 14OCT2016 variety, with and without hours/minutes * tests/allFormats.R: Add new tests as well diff --git a/DESCRIPTION b/DESCRIPTION index 163cc00..dd4d8ec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: anytime Type: Package Title: Anything to 'POSIXct' or 'Date' Converter -Version: 0.0.4.1 -Date: 2016-10-22 +Version: 0.0.4.2 +Date: 2016-10-23 Author: Dirk Eddelbuettel Maintainer: Dirk Eddelbuettel Description: Convert input in any one of character, integer, numeric, factor, diff --git a/src/anytime.cpp b/src/anytime.cpp index 0477655..2a1e464 100644 --- a/src/anytime.cpp +++ b/src/anytime.cpp @@ -60,6 +60,9 @@ const std::string sformats[] = { // see http://stackoverflow.com/questions/39259184/formatting-dates-with-r for next one "%a %b %d %H:%M:%S%F %Y", + // see RFC 822 and standard Unix use eg mail headers (but no TZ or UTC offset on input :-/ ) + "%a %d %b %Y %H:%M:%S%F", + "%Y-%m-%d", "%Y%m%d", "%m/%d/%Y", diff --git a/tests/allFormats.R b/tests/allFormats.R index 6097628..d29762e 100644 --- a/tests/allFormats.R +++ b/tests/allFormats.R @@ -35,6 +35,9 @@ anytime(c("01.September.2016 10:11:12", "01.September.2016 10:11:12.345678")) cat("\n") anytime(c("Thu Sep 01 10:11:12 2016", "Thu Sep 01 10:11:12.345678 2016")) +cat("\n") +anytime(c("Thu 01 Sep 2016 10:11:12", "Thu 01 Sep 2016 10:11:12.345678")) + cat("\n") anytime(c("2016-09-01", "20160901", "09/01/2016", "09-01-2016"))