Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,28 @@ on:
pull_request: {}

jobs:
resolve:
runs-on: ubuntu-latest
outputs:
MSRV: ${{ steps.resolve-msrv.outputs.MSRV }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false

- name: resolve MSRV
id: resolve-msrv
run: echo MSRV=`cargo metadata --format-version 1 --no-deps --frozen --quiet --offline --manifest-path Cargo.toml | jq -r '.packages[0].rust_version'` >> $GITHUB_OUTPUT
Comment thread
davidhewitt marked this conversation as resolved.
Resolved

test:
name: test rust-${{ matrix.rust-version }}
needs: [resolve]
strategy:
fail-fast: false
matrix:
rust-version: [stable, beta, nightly]
include:
- rust-version: ${{ needs.resolve.outputs.MSRV }}

runs-on: ubuntu-latest

Expand All @@ -24,25 +40,28 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
components: llvm-tools

- id: cache-rust
uses: Swatinem/rust-cache@v2

- run: cargo install rustfilt coverage-prepare
if: steps.cache-rust.outputs.cache-hit != 'true'
- uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov

- run: rustup component add llvm-tools-preview

- run: cargo test --test main
- run: cargo llvm-cov test --test main --codecov --output-path coverage.json
env:
RUST_BACKTRACE: 1
RUSTFLAGS: '-C instrument-coverage'

- run: coverage-prepare --ignore-filename-regex '/tests/' lcov $(find target/debug/deps -regex '.*/main[^.]*')

- run: cargo test --doc

- uses: codecov/codecov-action@v6
with:
files: coverage.json
disable_search: true


bench:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
name = "speedate"
authors = ["Samuel Colvin <s@muelcolvin.com>"]
version = "0.17.0"
edition = "2021"
edition = "2024"
description = "Fast and simple datetime, date, time and duration parsing"
readme = "README.md"
license = "MIT"
keywords = ["ISO8601", "RFC3339", "datetime", "date", "time"]
categories = ["date-and-time", "parsing"]
homepage = "https://github.com/pydantic/speedate/"
repository = "https://github.com/pydantic/speedate/"
# MSRV should match pydantic-core
rust-version = "1.88"

[dependencies]
arrayvec = { version = "0.7.6", default-features = false }
Expand Down
12 changes: 6 additions & 6 deletions src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::fmt;
use core::str::FromStr;

use crate::config::TimeConfigBuilder;
use crate::{get_digit, get_digit_unchecked, ConfigError, ParseError, TimeConfig};
use crate::{ConfigError, ParseError, TimeConfig, get_digit, get_digit_unchecked};

/// A Time
///
Expand Down Expand Up @@ -430,10 +430,10 @@ impl Time {
/// assert_eq!(t2.to_string(), "12:13:14-08:00");
/// ```
pub fn with_timezone_offset(&self, tz_offset: Option<i32>) -> Result<Self, ParseError> {
if let Some(offset_val) = tz_offset {
if offset_val.abs() >= 24 * 3600 {
return Err(ParseError::OutOfRangeTz);
}
if let Some(offset_val) = tz_offset
&& offset_val.abs() >= 24 * 3600
{
return Err(ParseError::OutOfRangeTz);
}
let mut time = *self;
time.tz_offset = tz_offset;
Expand Down Expand Up @@ -552,7 +552,7 @@ impl PureTime {
match config.microseconds_precision_overflow_behavior {
MicrosecondsPrecisionOverflowBehavior::Truncate => continue,
MicrosecondsPrecisionOverflowBehavior::Error => {
return Err(ParseError::SecondFractionTooLong)
return Err(ParseError::SecondFractionTooLong);
}
}
}
Expand Down
Loading