Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff committed Aug 12, 2024
2 parents 8ad50be + 5d4bc66 commit 0ad3238
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 121 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
49 changes: 17 additions & 32 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,40 @@
name: CI
on:
pull_request:
push:
branches:
- main
tags: '*'
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
actions: write
contents: read
strategy:
fail-fast: false
matrix:
version:
- '1'
- 'nightly'
- '1.10'
- 'pre'
os:
- ubuntu-latest
# - macOS-latest
# - windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-docdeploy@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
38 changes: 6 additions & 32 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,16 @@ on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'


File renamed without changes.
21 changes: 18 additions & 3 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
name: TagBot
on:
issue_comment: # THIS BIT IS NEW
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: "3"
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
# THIS 'if' LINE IS NEW
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
# NOTHING BELOW HAS CHANGED
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}

2 changes: 2 additions & 0 deletions .github/workflows/docs.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


28 changes: 0 additions & 28 deletions .github/workflows/docs.yml

This file was deleted.

14 changes: 5 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ license = "MIT"
authors = ["Jeffrey Sarnoff <jeffrey.sarnoff@gmail.com>"]
description = "NanoDate is a nanosecond resolved DateTime type"
repo = "https://github.com/JuliaTime/NanoDates.jl.git"
version = "0.3.3"
version = "0.4.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"

[compat]
Aqua = "0.5, 0.6, 0.7, 0.8"
Documenter = "1"
DocumenterTools = "0.1, 0.2, 0.3"
LiveServer = "1"
Parsers = "2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8"
Test = "1.7"
Dates = "1.7"
Aqua = "0.7 - 0.15"
Parsers = "2 - 3"
julia = "1.7"

[extras]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Latest
- performant NanoDate ranges with steps that are simple or compound periods
- much faster than Dates with compound period stepsizes
- bugfix (parsing some subsecond layouts)

- Contributors are welcome
- clear code, robust performance, reliable interoperability
Expand Down
1 change: 0 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ makedocs(
authors="Jeffrey Sarnoff",
source="src",
clean=false,
strict=!("strict=false" in ARGS),
doctest=("doctest=only" in ARGS) ? :only : true,
format=Documenter.HTML(
# Use clean URLs, unless built as a "local" build
Expand Down
15 changes: 7 additions & 8 deletions src/strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,13 @@ Base.lastindex(::Nothing) = nothing

function NanoDate(str::AbstractString, df::DateFormat=ISONanoDateFormat; localtime=false)
isnothing(str) || isempty(str) && throw(ArgumentError("nanodate_string cannot be empty"))
if '_' in str
str = join(split(str, '_'))
end
indices = indexperiods(df)
somethings = map(!isnothing, Tuple(indices))
somekeys = keys(indices)[[somethings...]]
someindices = NamedTuple{somekeys}(indices)
if maximum(last.(Tuple(someindices))) != length(str)
if df !== ISONanoDateFormat
throw(ArgumentError("$(str) does not match dateformat"))
else
return simpleparse(indices, str)
end
end
parts = getparts(indices, str)
subsecs = isnothing(parts.ss) ? (0,0,0) : tosubsecs(parts.ss)
offsets = isnothing(parts.offset) ? (0,0) : tooffset(parts.offset)
Expand Down Expand Up @@ -324,8 +320,11 @@ getparts(indices::NamedTuple, str::AbstractString) =
map(x -> getpart(x, str), indices)

function getpart(r::UnitRange, str)
if iszero(r.start)
n = length(str)
if iszero(r.start) || r.start > n
"0"
elseif r.stop > n
str[r.start:n]
else
str[r]
end
Expand Down
9 changes: 1 addition & 8 deletions test/strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,5 @@ end
@test NanoDate(2022,5,24,18,26,21,0,0,900) == NanoDate("2022-05-24T18:26:21.0000009")
@test NanoDate(2022,5,24,18,26,21,0,0,90) == NanoDate("2022-05-24T18:26:21.00000009")
@test NanoDate(2022,5,24,18,26,21,0,0,9) == NanoDate("2022-05-24T18:26:21.000000009")
end
end



@test NanoDate("2022-04-28 02:15:30") == NanoDate("2022-04-28T02:15:30")
@test NanoDate("2022-04-28 02:15:30.12") == NanoDate("2022-04-28T02:15:30.12")
@test NanoDate("2022-04-28 02:15:30.123") == NanoDate("2022-04-28T02:15:30.123")
@test NanoDate("2022-04-28 02:15:30.1234") == NanoDate("2022-04-28T02:15:30.1234")
end

0 comments on commit 0ad3238

Please sign in to comment.