All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Option to parse numerals. Numerals can occur where usually a number would be expected (#23)
- BREAKING: Rename of the function
allow_delimiter
toallow_time_unit_delimiter
- BREAKING: The 4 different delimiters are now unified into an
inner
andouter
delimiter. The functionsallow_ago
,allow_sign_delimiter
andallow_time_unit_delimiter
now use theinner
delimiter and don't take a definition of aDelimiter
anymore. Theparse_multiple
now uses theouter
delimiter and doesn't take an argument for the definition of aDelimiter
anymore. Theinner
andouter
delimiters can be defined with extra functions, instead. (#34) - Improve the general parsing speed, especially for input with fractions
- fundu's
Duration
has now additional methods: as_weeks, as_days, as_hours, as_minutes, as_seconds, as_millis, as_micros, as_nanos, subsec_millis, subsec_micros, subsec_nanos, extract_weeks, extract_days, extract_hours, extract_minutes, extract_seconds - Optionally allow a delimiter between the sign and a number, time keyword etc with the
configuration option
allow_sign_delimiter
(#28)
- When
parse_multiple
is set, a sign character can now also indicate a new duration (#24) - Increase performance of parsing time keywords and time units without a number when
number_is_optional
is set - Development dependencies are updated:
- pprof v0.11.1 -> v0.12.0
- criterion v0.4.0 -> v0.5.1
- rstest v0.17.0 -> v0.18.1
- rstest_reuse v0.5.0 -> v0.6.0
- Bump fundu-core dependency from
v0.1.0
tov0.2.0
- When
parse_multiple
together withnumber_is_optional
was set, then a single sign character was interpreted as a duration of 1 second (#32)
fundu
has a new featurebase
which provides greater freedom than thecustom
feature- Implementation of
Clone
andHash
forParseError
andTryFromDurationError
- Big internal restructuring which splits fundu into a
fundu-core
andfundu
package - Internal refactor of
fundu-core
- The minimum supported rust version changed from
1.61.0
to1.64.0
- The optional
time
dependency was updated from0.3.16
to0.3.20
If upgrading from an previous version, there are some breaking changes, most notably parsing
negative durations has been completely revised. The negative
feature was removed and the parsers
now return fundu's own Duration
, which can represent negative Durations
, instead of a
std::time::Duration
(or time::Duration
).
- A new configuration option
allow_negative
to enable parsing negativeDurations
without parsing error chrono
feature to provide methods to convert from fundu'sDuration
tochrono::Duration
and vice versatime
feature to provide methods to convert from fundu'sDuration
totime::Duration
and vice versaserde
feature to be able to serialize, deserialize the some important structs and enums withserde
:ParseError
,TryFromDurationError
,Multiplier
,Duration
- New trait
SaturatingInto
which provides a method to convert from fundu'sDuration
into anotherDuration
saturating at the maximum or minimum of the otherDuration
instead of returning aTryFromDurationError
. - A new error type
TryFromDurationError
which is returned when the conversion from fundu'sDuration
tostd::time::Duration
,time::Duration
orchrono::Duration
fails. - Add a new struct
TimeKeyword
to thecustom
feature.TimeKeywords
(likeyesterday
) are similar toCustomTimeUnits
but don't accept a number in front of them in the input string. - The
CustomDurationParser
andCustomDurationParserBuilder
have two new methodskeyword
andkeywords
which storeTimeKeyword
(s) in the parser. - A new configuration option
allow_ago
was added to enable parsing theago
keyword in the input string after a duration to negate the previously parsed duration CustomTimeUnit::with_default
: This method creates aCustomTimeUnit
with the default multiplier ofMultiplier(1, 0)
- Implementation of the standard trait
Hash
forCustomTimeUnit
,TimeUnit
andMultiplier
- New methods for
Multiplier
:is_negative
,is_positive
,checked_mul
,saturating_neg
and the getterscoefficient
for the first component andexponent
for the second
-
Fundu's thus far internally used
Duration
is now public and implements most standard arithmetic traits likeAdd
,Sub
etc. It can also be converted tostd::time::Duration
and if the feature is activatedtime::Duration
,chrono::Duration
-
BREAKING: The
DurationParser::parse
andCustomDurationParser::parse
methods now return fundu's ownDuration
instead ofstd::time::Duration
-
BREAKING: The
Multiplier
changed from (u64, i16) to (i64, i16) to allow negativeMultipliers
-
BREAKING: The
parse_multiple
configuration option now optionally allows conjunction words (likeand
) between durations in the input string in addition to aDelimiter
-
BREAKING: The
DurationParserBuilder
can now build theDurationParser
inconst
context at compile time. To be able to do so, the methods signatures of theDurationParserBuilder
changed from(&mut self) -> &mut Self
to(mut self) -> Self
-
BREAKING: Rename
DurationParserBuilder::custom_time_units
->DurationParserBuilder::time_units
-
BREAKING: The
SYSTEMD_TIME_UNITS
,DEFAULT_TIME_UNITS
andDEFAULT_ALL_TIME_UNITS
constants from thecustom
feature now useCustomTimeUnit
s instead of a tuple. -
BREAKING: Remove
CustomDurationParserBuilder::time_unit
and renameCustomDurationParserBuilder::custom_time_unit
->CustomDurationParserBuilder::time_unit
-
BREAKING: Remove
CustomDurationParserBuilder::time_units
and renameCustomDurationParserBuilder::custom_time_units
->CustomDurationParserBuilder::time_units
-
BREAKING:
CustomDurationParser::with_time_units
now usesCustomTimeUnits
instead of theIdentifier
type -
BREAKING: Rename
CustomDurationParser::custom_time_unit
->CustomDurationParser::time_unit
-
BREAKING: Rename
CustomDurationParser::custom_time_units
->CustomDurationParser::time_units
-
BREAKING: If the setting
number_is_optional
is enabled the exponent must have a mantissa. The exponent is now a part of the number -
Panic in
CustomTimeUnit::new
when creating aCustomTimeUnit
with aMultiplier
andTimeUnit
. A multiplication of the additionalMultiplier
and the inherent multiplier of theTimeUnit
would otherwise overflow (and panic) during the parsing -
Refactorings of the internal parser improve the parsing speed for all input sizes
- BREAKING: The
negative
feature andDurationParser::parse_negative
,CustomDurationParser::parse_negative
- BREAKING: The
Identifier
type is redundant and was removed
- Parsing with the configuration option
allow_delimiter
enabled changed, so that an input ending with aDelimiter
is an error now - The exponent must always consist of at least one digit
- Input starting with a delimiter should result in a ParseError similar to input ending with a delimiter
This version introduces a slight performance regression in favour of the new parse_multiple
method.
- New method
parse_multiple
to parse multiple durations in the source string at once. - New method
disable_infinity
to disable parsinginf
orinfinity
. - The new methods above make it possible to build a systemd time span parser as defined by systemd
- An example for a fully functional systemd time span parser
- Parsing
infinity
values was improved, so that time unit identifiers can now start with ani
orin
. - Running the benchmarks was improved, so that
iai
(feature =with-iai
) andflamegraph
(feature =with-flamegraph
) benchmarks need to be activated via their features. - Make
TimeUnit::multiplier
method public - Make
custom::Identifiers
type public
- In the
parser
module an invocation ofParseError::TimeUnit
error was pointing to a wrong position in the source string. - Use a workaround on s390x systems because parsing negative durations produced wrong results when
using
time::Duration::MIN.saturating_add
. The source of this bug is maybe thetime
crate orrust
itself.
negative
feature: parse negative durations to a duration from thetime
crate- The number format is now customizable:
- allow one ore more delimiter between the number and the time unit by setting a
Delimiter
- disable parsing an exponent
- disable parsing a fraction
- make numbers in front of time units and exponents optional
- allow one ore more delimiter between the number and the time unit by setting a
DurationParser::builder
method andDurationParserBuilder
CustomDurationParser
allows now creating completely newCustomTimeUnit
sCustomDurationParser::builder
method andCustomDurationParserBuilder
- An example for the
custom
feature
- The minimum supported rust version changed from
1.60.0
to1.61.0
- Some internal changes and refactorings improved the overall performance
- Improve and enhance the
README
and public api documentation
DurationParser::time_unit
andDurationParser::time_units
: UseDurationParser::with_time_units
or theDurationParserBuilder
insteadCustomDurationParser::get_current_time_units
- Change from
iai
toiai-callgrind
and use the new features to improve the iai benchmarks
- Building the docs on docs.rs should use all features
- Internal changes to improve the overall performance but especially for large inputs. Parsing large inputs is now faster than the reference function.
- The exponent maximum/minium changed to i16 bounds.
- Make most initialization methods of
DurationParser
applicable inconst
context - Some internal refactors improved the initialization and parsing speeds
- Apply cfg attributes in builder mod.rs. This fixes the warnings when not all features were given.
- The
custom
feature adds fully customizable identifiers for time units in a new structCustomDurationParser
- Add
cachegrind
based benchmarks in the githubCI
- Organize project into features:
standard
(default) andcustom
- Include more error types in
ParseError
and makeParseError
non exhaustive - Improve performance of time unit parsing
- Improve and add more benchmarks
- The
DurationParser::parse
method usedself
mutable although this was not necessary
- New builder method
DurationParser::default_unit
to set the default time unit to something different than seconds. - New method
DurationParser::get_time_units
which returns the current set of time units. - More runnable examples/recipes in the
examples
folder.
- Improve the api and crate level documentation
- Update the README and api documentation to better document the handling of values close to zero no matter the sign.
- Remove
TimeUnit::multiplier
from the public api. It's still used internally.
- Parsing the exponent if there is no number must return a
ParseError
- Negative values exceeding
u64::MAX
returnedDuration::MAX
. Now aParseError
is returned.
- Fix panic in parser when the whole and fraction part of the input number are missing but a dot is given
- New method
TimeUnits::get_time_units
which returns all currently active time units PartialOrd, Ord
traits implementation forTimeUnit
- Improve overall performance by 10-20%
- Improve performance of parsing with time units by a factor of ~15 (before ~800ns -> after ~55ns)
- tests: Improve test coverage. Reach full coverage.
- tests: Increase accuracy of benchmarks
- CI: Use
grcov
for coverage report creation with the more accurate source-based coverage
- More tests
- Add a simple example in examples directory
- Updated the README, library documentation and provide more examples
- Rename
DurationParser::with_no_time_units
->DurationParser::without_time_units
- Change to Julian year calculation: 1 year = 365.25 days and 1 month = year / 12
- Refactor test structure
- Make the default ids of time units available
- Unneeded constants
SECONDS_MAX
andNANOS_MAX
- Fix a possible overflow when multiplying attos with the time unit multiplier
- Export
error::ParseError
and make this enum public
- Basic working implementation of the duration parser
- Tests and benchmarks
- A README
- Basic api documentation
- This Changelog
- CI setup with github actions