Skip to content

Commit

Permalink
version 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
schochastics authored and cran-robot committed Jul 5, 2024
1 parent ca74050 commit 32d16fa
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 92 deletions.
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: timeless
Title: Fast General Purpose Date/Time Converter
Version: 0.2.2
Version: 0.2.3
Authors@R:
c(person("David", "Schoch", , "david@schochastics.net", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2952-4812")),
Expand All @@ -16,14 +16,15 @@ URL: https://github.com/schochastics/timeless,
BugReports: https://github.com/schochastics/timeless/issues
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.0
Config/rextendr/version: 0.3.1
RoxygenNote: 7.3.1
Config/rextendr/version: 0.3.1.9000
Depends: R (>= 3.6)
LazyData: true
Suggests: testthat (>= 3.0.0)
Config/testthat/edition: 3
SystemRequirements: Cargo (Rust's package manager), rustc
NeedsCompilation: yes
Packaged: 2024-07-02 13:21:19 UTC; david
Packaged: 2024-07-04 17:32:37 UTC; david
Author: David Schoch [aut, cre] (<https://orcid.org/0000-0003-2952-4812>),
Rollie Ma [ctb, cph] (author of dateparser :
<https://github.com/waltzofpearls/dateparser>),
Expand All @@ -39,4 +40,4 @@ Author: David Schoch [aut, cre] (<https://orcid.org/0000-0003-2952-4812>),
<https://github.com/chronotope/chrono>)
Maintainer: David Schoch <david@schochastics.net>
Repository: CRAN
Date/Publication: 2024-07-02 14:30:02 UTC
Date/Publication: 2024-07-04 22:50:02 UTC
17 changes: 9 additions & 8 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
a17168290db3201f57e7b28ec299d07b *DESCRIPTION
d3c654d8345e2ab308bbad4e8ab2ed02 *DESCRIPTION
4fb8f8da25f17fba61e6989ccba7858c *LICENSE
34c7733e01902094051ba395273303cf *NAMESPACE
057fd9feb2f952265493581bbf718187 *NEWS.md
8e9b34388da1254625bb1e8aa2874072 *NEWS.md
3cf1d565349637b59d717d75476ddc90 *R/chronos.R
c16a7e93a97d913a43f464a5d510e815 *R/data.R
ac339980ee82bda8ce97251c0abcca7e *R/extendr-wrappers.R
c42f61f3f534134785a52307afbe0d8b *R/extendr-wrappers.R
4fa2da56eed2a9cbb1daccc1f22847d9 *R/sysdata.rda
e2c36f34981baeddcb66472545f68a83 *R/utils.R
9ca7416c2dc62d7fbe667434a75786e0 *README.md
504d7a81d3d01370067c8b39791a16b1 *README.md
7ab84fb76c0c016a33e21555fae24af7 *configure
6f1afa52394eba61cfef215155aed8c2 *configure.win
cb8d4f8f23884c6d05624dbd0d766048 *data/bench_date.rda
f5fa20383ffd247d0a2c139ec0677788 *man/bench_date.Rd
98a6a44b658e7e5766b2ac92a8e84393 *man/chronos.Rd
e0161e4caa6e1dca090c91fd2b040689 *man/figures/logo.png
ef668119f463704e9d769f2eb292c5de *man/parse_date.Rd
833eb6e24d2ad9e7bf6ccee1df0243a6 *man/parse_datetime.Rd
46a5506d7fdda3cb3c1d56916a90b2c4 *man/parse_epoch.Rd
278f805534e5f77cfa9afb997fc1e63e *man/timeless-package.Rd
8d60da1d2fa4713bb60b25a3500e5424 *src/Makevars
7ddab0326322e037dc1ae72caa263604 *src/Makevars
27957123fba16c05c53a66e68b0f3482 *src/Makevars.ucrt
6936be2d792c17db290280ad8bae0a5c *src/Makevars.win
5b3f2967c0543020a480d78d3ce0f2dd *src/Makevars.win
4a41c24c8f0db97e2add7a7cd83600ad *src/entrypoint.c
e69a92654ad4bcd1630c52c0e580095d *src/rust/Cargo.lock
dd4a46e51e793eceecb63736c5eb320a *src/rust/Cargo.toml
a895fbfd0efa897091a0c48400d095db *src/rust/src/lib.rs
12e7d9bc505f910c95ada4d2642445e4 *src/rust/src/lib.rs
73c8f3cd924fa9a6538be5bd9ebf1201 *src/timeless-win.def
2752f22f250cc644587a0d9024fa51fd *tests/testthat.R
b93d34f1af283b72939809881cd84ab4 *tests/testthat/test-timeless.R
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# timeless 0.2.3

* proper Makefile and pkg vendoring #19
* fix deprecated warnings #20

# timeless 0.2.2

* fix CRAN issue due to C level changes h/t @JosiahParry
Expand Down
2 changes: 1 addition & 1 deletion R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#' @usage NULL
#' @useDynLib timeless, .registration = TRUE
"_PACKAGE"
NULL

parse_guess_rs <- function(times) .Call(wrap__parse_guess_rs, times)

Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,40 +113,40 @@ chronos(bench_date, out_format = "datetime")
#> [21] "2017-11-25 21:31:00 CET" "2014-12-16 06:20:00 CET"
#> [23] "2014-12-16 06:20:00 CET" "2014-04-26 05:13:43 CEST"
#> [25] "2014-04-26 04:13:44 CEST" "2012-08-03 18:31:59 CEST"
#> [27] "2015-09-30 18:48:56 CEST" "2021-02-21 05:24:46 CET"
#> [29] "2021-02-22 05:24:46 CET" "2021-02-21 05:24:46 CET"
#> [31] "2020-07-20 05:24:46 CEST" "2024-03-29 00:06:06 CET"
#> [33] "2024-03-29 15:00:00 CET" "2024-03-29 05:00:00 CET"
#> [35] "2024-03-28 09:06:06 CET" "2024-03-29 00:00:00 CET"
#> [37] "2024-03-28 14:00:00 CET" "2024-03-29 18:00:00 CET"
#> [27] "2015-09-30 18:48:56 CEST" "2021-02-21 08:09:09 CET"
#> [29] "2021-02-22 07:09:09 CET" "2021-02-21 07:09:09 CET"
#> [31] "2020-07-20 07:09:09 CEST" "2024-07-03 23:06:06 CEST"
#> [33] "2024-07-04 14:00:00 CEST" "2024-07-04 04:00:00 CEST"
#> [35] "2024-07-03 09:06:06 CEST" "2024-07-04 00:00:00 CEST"
#> [37] "2024-07-03 14:00:00 CEST" "2024-07-04 18:00:00 CEST"
#> [39] "2024-05-06 19:24:00 CEST" "2024-05-27 00:45:27 CEST"
#> [41] "2009-05-08 15:57:51 CEST" "2012-09-17 08:09:00 CEST"
#> [43] "2012-09-17 08:10:09 CEST" "2021-05-02 15:51:31 CEST"
#> [45] "2021-05-02 15:51:00 CEST" "2021-05-26 07:49:00 CEST"
#> [47] "2012-09-17 18:09:00 CEST" "2021-02-21 05:24:46 CET"
#> [49] "2021-05-25 04:24:46 CEST" "1970-10-07 05:24:46 CET"
#> [51] "1970-10-07 05:24:46 CET" "1970-10-07 05:24:46 CET"
#> [53] "1970-10-07 05:24:46 CET" "1970-10-07 05:24:46 CET"
#> [47] "2012-09-17 18:09:00 CEST" "2021-02-21 08:09:09 CET"
#> [49] "2021-05-25 07:09:09 CEST" "1970-10-07 08:09:09 CET"
#> [51] "1970-10-07 08:09:09 CET" "1970-10-07 08:09:09 CET"
#> [53] "1970-10-07 08:09:09 CET" "1970-10-07 08:09:09 CET"
#> [55] "2006-02-12 18:17:00 CET" "2006-02-12 18:17:00 CET"
#> [57] "2019-05-14 17:11:40 CEST" "1970-10-07 05:24:46 CET"
#> [59] "1970-10-07 05:24:46 CET" "2013-02-03 05:24:46 CET"
#> [61] "2013-07-01 04:24:46 CEST" "2014-04-08 20:05:00 CEST"
#> [57] "2019-05-14 17:11:40 CEST" "1970-10-07 08:09:09 CET"
#> [59] "1970-10-07 08:09:09 CET" "2013-02-03 08:09:09 CET"
#> [61] "2013-07-01 07:09:09 CEST" "2014-04-08 20:05:00 CEST"
#> [63] "2014-04-08 20:05:00 CEST" "2014-04-08 20:05:00 CEST"
#> [65] "2014-02-04 03:00:51 CET" "1965-08-07 23:00:00 CET"
#> [67] "1965-08-08 12:00:01 CET" "1965-08-08 13:00:00 CET"
#> [69] "1965-08-08 13:00:00 CET" "1965-08-08 00:00:00 CET"
#> [71] "2014-02-04 03:00:51 CET" "2012-03-19 10:11:59 CET"
#> [73] "2012-03-19 09:11:59 CET" "2014-03-31 04:24:46 CEST"
#> [75] "2014-03-31 04:24:46 CEST" "1971-08-21 05:24:46 CET"
#> [77] "1971-08-01 05:24:46 CET" "2014-04-08 20:05:00 CEST"
#> [73] "2012-03-19 09:11:59 CET" "2014-03-31 07:09:09 CEST"
#> [75] "2014-03-31 07:09:09 CEST" "1971-08-21 08:09:09 CET"
#> [77] "1971-08-01 08:09:09 CET" "2014-04-08 20:05:00 CEST"
#> [79] "2014-04-08 20:05:00 CEST" "2014-04-02 03:00:51 CEST"
#> [81] "2014-04-02 03:00:51 CEST" "2012-03-19 10:11:59 CET"
#> [83] "2012-03-19 09:11:59 CET" "2014-03-31 04:24:46 CEST"
#> [85] "2014-03-31 04:24:46 CEST" "2014-03-31 04:24:46 CEST"
#> [87] "2014-03-31 04:24:46 CEST" "1971-08-21 05:24:46 CET"
#> [89] "2014-03-30 04:24:46 CEST" "2014-03-29 05:24:46 CET"
#> [83] "2012-03-19 09:11:59 CET" "2014-03-31 07:09:09 CEST"
#> [85] "2014-03-31 07:09:09 CEST" "2014-03-31 07:09:09 CEST"
#> [87] "2014-03-31 07:09:09 CEST" "1971-08-21 08:09:09 CET"
#> [89] "2014-03-30 07:09:09 CEST" "2014-03-04 08:09:09 CET"
#> [91] "2017-11-13 13:14:20 CET" "2014-04-08 09:25:18 CEST"
#> [93] "2014-04-08 04:24:46 CEST"
#> [93] "2014-04-08 07:09:09 CEST"
```

## Functions
Expand Down Expand Up @@ -239,11 +239,11 @@ microbenchmark::microbenchmark(
)
#> Unit: microseconds
#> expr min lq mean median uq
#> chronos(bench_date) 896.271 980.694 1182.24 1106.29 1285.36
#> anytime::anytime(bench_date) 30462.110 34285.474 38231.60 36191.40 41504.53
#> chronos(bench_date) 898.682 990.799 1161.85 1106.01 1217.82
#> anytime::anytime(bench_date) 30551.881 32954.088 37309.36 35526.34 38581.95
#> max neval
#> 2147.17 100
#> 54899.96 100
#> 2890.17 100
#> 67170.21 100
```

See [this
Expand Down
20 changes: 20 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env sh

# https://github.com/eitsupi/prqlr/blob/main/configure
export PATH="$PATH:$HOME/.cargo/bin"

if [ ! "$(command -v cargo)" ]; then
echo "----------------------- [RUST NOT FOUND]---------------------------"
echo "The 'cargo' command was not found on the PATH. Please install rustc"
echo "from: https://www.rust-lang.org/tools/install"
echo ""
echo "Alternatively, you may install cargo from your OS package manager:"
echo " - Debian/Ubuntu: apt-get install cargo"
echo " - Fedora/CentOS: dnf install cargo"
echo " - macOS: brew install rustc"
echo "-------------------------------------------------------------------"
echo ""
exit 1
fi

exit 0
15 changes: 15 additions & 0 deletions configure.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# https://github.com/eitsupi/prqlr/blob/main/configure.win
export PATH="$PATH:$HOME/.cargo/bin"

if [ ! "$(command -v cargo)" ]; then
echo "----------------------- [RUST NOT FOUND]---------------------------"
echo "The 'cargo' command was not found on the PATH. Please install rustc"
echo "from: https://www.rust-lang.org/tools/install"
echo "-------------------------------------------------------------------"
echo ""
exit 1
fi

exit 0
35 changes: 0 additions & 35 deletions man/timeless-package.Rd

This file was deleted.

21 changes: 13 additions & 8 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@ PKG_LIBS = -L$(LIBDIR) -ltimeless

all: C_clean

CRAN_FLAGS=-j 2
$(SHLIB): $(STATLIB)

CRAN_FLAGS=-j 2
CARGOTMP = $(CURDIR)/.cargo
VENDOR_DIR = $(CURDIR)/vendor

$(STATLIB):
if [ -f ./rust/vendor.tar.xz ]; then \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
fi

# In some environments, ~/.cargo/bin might not be included in PATH, so we need
# to set it here to ensure cargo can be invoked. It is appended to PATH and
# therefore is only used if cargo is absent from the user's PATH.
if [ "$(NOT_CRAN)" != "true" ]; then \
export CARGO_HOME=$(CARGOTMP); \
fi && \
export PATH="$(PATH):$(HOME)/.cargo/bin" && \
cargo build $(CRAN_FLAGS) --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)
if [ "$(NOT_CRAN)" != "true" ]; then \
rm -Rf $(CARGOTMP) && \
rm -Rf $(LIBDIR)/build; \
fi
cargo build $(CRAN_FLAGS) --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR) && \
echo `cargo --version` && echo `rustc --version`;
rm -Rf $(CARGOTMP) $(VENDOR_DIR) $(LIBDIR)/build; \

C_clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(CARGOTMP) $(VENDOR_DIR)

clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) rust/target
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(CARGOTMP) $(VENDOR_DIR) $(TARGET_DIR)
28 changes: 21 additions & 7 deletions src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@ all: C_clean

$(SHLIB): $(STATLIB)

CRAN_FLAGS=-j 2
CARGOTMP = $(CURDIR)/.cargo
VENDOR_DIR = $(CURDIR)/vendor

all: C_clean

$(SHLIB): $(STATLIB)

CRAN_FLAGS=-j 2
CARGOTMP = $(CURDIR)/.cargo

$(STATLIB):
# uncompress vendored deps
if [ -f ./rust/vendor.tar.xz ]; then \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
fi

mkdir -p $(TARGET_DIR)/libgcc_mock
# `rustc` adds `-lgcc_eh` flags to the compiler, but Rtools' GCC doesn't have
# `libgcc_eh` due to the compilation settings. So, in order to please the
# compiler, we need to add empty `libgcc_eh` to the library search paths.
#
# For more details, please refer to
# https://github.com/r-windows/rtools-packages/blob/2407b23f1e0925bbb20a4162c963600105236318/mingw-w64-gcc/PKGBUILD#L313-L316
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a
Expand All @@ -27,15 +41,15 @@ $(STATLIB):
export CARGO_HOME=$(CARGOTMP); \
fi && \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \
export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \
cargo build $(CRAN_FLAGS) --target=$(TARGET) --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)
export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock"; \
cargo build $(CRAN_FLAGS) --target=$(TARGET) --lib --release --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR) && \
echo `cargo --version` && echo `rustc --version`;
if [ "$(NOT_CRAN)" != "true" ]; then \
rm -Rf $(CARGOTMP) && \
rm -Rf $(LIBDIR)/build; \
rm -Rf $(CARGOTMP) $(VENDOR_DIR) $(LIBDIR)/build; \
fi

C_clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(CARGOTMP) $(VENDOR_DIR)

clean:
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(TARGET_DIR)
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(CARGOTMP) $(VENDOR_DIR) $(TARGET_DIR)
6 changes: 3 additions & 3 deletions src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn parse_date_rs(times: Vec<String>, formats: Vec<String>, out_format: &str) ->
.map(|time_str| {
for fmt in &formats {
if let Ok(date) = NaiveDate::parse_from_str(time_str, fmt) {
let naive_datetime = date.and_hms(0, 0, 0);
let naive_datetime = date.and_hms_milli_opt(0, 0, 0, 0).unwrap();
return naive_datetime.format(out_format).to_string();
}
}
Expand All @@ -54,7 +54,7 @@ fn parse_epoch_rs(times: Vec<String>, out_format: &str) -> Vec<String> {
.iter()
.map(|time_str| {
if let Ok(epoch_seconds) = time_str.parse::<i64>() {
let naive_date_time = NaiveDateTime::from_timestamp(epoch_seconds, 0);
let naive_date_time = NaiveDateTime::from_timestamp_opt(epoch_seconds, 0).unwrap();
return naive_date_time.format(out_format).to_string();
}
"not found".to_string()
Expand All @@ -67,7 +67,7 @@ fn parse_epoch_i64_rs(times: Vec<i32>, out_format: &str) -> Vec<String> {
times
.iter()
.map(|&epoch| {
let naive_date_time = NaiveDateTime::from_timestamp(epoch.into(), 0);
let naive_date_time = NaiveDateTime::from_timestamp_opt(epoch.into(), 0).unwrap();
naive_date_time.format(out_format).to_string()
})
.collect()
Expand Down

0 comments on commit 32d16fa

Please sign in to comment.