Skip to content

Commit

Permalink
fix datetime to character conversion (#495)
Browse files Browse the repository at this point in the history
* fix datetime to character conversion

* patch bump

* try other julia versions on windows

* more extensive R testing, only test windows on Julia latest
  • Loading branch information
palday committed Aug 9, 2023
1 parent 7f59101 commit 305efff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Julia ${{ matrix.version }} - R ${{ matrix.R }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
Expand All @@ -19,6 +19,10 @@ jobs:
- '1.6'
- '1'
- nightly
R:
- 'release'
- '4.0'
- '3.4'
os: [ubuntu-latest]
arch: [x64]
experimental: [false]
Expand All @@ -28,10 +32,12 @@ jobs:
arch: x64
version: 1
experimental: false
R: 'release'
- os: windows-latest
arch: x64
version: 1
experimental: false
R: 'release'
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand All @@ -42,6 +48,7 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
r-version: ${{ matrix.R }}
- run: echo "LD_LIBRARY_PATH=$(R RHOME)/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest'
- uses: julia-actions/julia-buildpkg@v1
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RCall"
uuid = "6f49c342-dc21-5d91-9882-a32aef131414"
authors = ["Douglas Bates <dmbates@gmail.com>", "Randy Lai <randy.cs.lai@gmail.com>", "Simon Byrne <simonbyrne@gmail.com>"]
version = "0.13.15"
version = "0.13.16"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down
12 changes: 9 additions & 3 deletions test/convert/datetime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ r = RObject(d)
@test rcopy(r) === d
@test rcopy(DateTime, r) === d
@test rcopy(R"as.POSIXct($s, 'UTC', '%Y-%m-%dT%H:%M:%S')") == d
@test rcopy(R"identical(as.character($d, '%Y-%m-%dT%H:%M:%S'), $s)")
# previously the second argument to as.character.POSIXt was `format``, now it defaults
# to `digits`. Using `format` as a named argument gives a deprecation warning
# this changed in R 4.3.0 but is listed as a bugfix
# > as.character(<POSIXt>) now behaves more in line with the methods for atomic vectors such as numbers,
# > and is no longer influenced by options(). Ditto for as.character(<Date>). The as.character() method
# > gets arguments digits and OutDec with defaults not depending on options(). Use of as.character(*, format = .) now warns.
@test rcopy(R"identical(format($d, '%Y-%m-%dT%H:%M:%S'), $s)")


s = ["2001-01-01T01:01:01", "1111-11-11T11:11:00", "2012-12-12T12:12:12"]
Expand All @@ -88,7 +94,7 @@ r = RObject(d)
@test rcopy(r) == d
@test rcopy(Array{DateTime}, r) == d
@test rcopy(R"as.POSIXct($s, 'UTC', '%Y-%m-%dT%H:%M:%S')") == d
@test rcopy(R"identical(as.character($d, '%Y-%m-%dT%H:%M:%S'), $s)")
@test rcopy(R"identical(format($d, '%Y-%m-%dT%H:%M:%S'), $s)")


# SubArray
Expand All @@ -103,7 +109,7 @@ r = RObject(d)
@test rcopy(r) == d
@test rcopy(Array{DateTime}, r) == d
@test rcopy(R"as.POSIXct($s[1:2], 'UTC', '%Y-%m-%dT%H:%M:%S')") == d
@test rcopy(R"identical(as.character($d, '%Y-%m-%dT%H:%M:%S'), $s[1:2])")
@test rcopy(R"identical(format($d, '%Y-%m-%dT%H:%M:%S'), $s[1:2])")


d = DateTime[]
Expand Down

2 comments on commit 305efff

@palday
Copy link
Collaborator Author

@palday palday commented on 305efff Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/89352

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.16 -m "<description of version>" 305efff4cf31d89b79f1943f26e1ccd9658928a8
git push origin v0.13.16

Please sign in to comment.