Module clipivot::parsing

source ·
Expand description

The module for customized parsing of types for the command-line program.

The two objects, CustomDateObject and DecimalWrapper are simple wrappers over existing data types – chrono::NaiveDateTime in the case of CustomDateObject and rust_decimal::Decimal in the case of DecimalWrapper.

This is necessary because chrono doesn’t use FromStr (because it doesn’t know the format it needs to parse) and because I wanted to return the number of days between datetimes for range (overwriting std::ops::Sub). And decimal has a way of parsing values in scientific notation and parsing normal numbers. So I added the scientific notation parsing to the implementation of FromStr.

Structs

  • A light wrapper over chrono::NaiveDateTime. Also implements std::ops::Sub to compute the total number of days between two dates. This is probably not smart, but it allows me to easily run Range on dates.
  • A light wrapper over rust_decimal::Decimal.

Functions

  • Sets INPUT_DATE_FORMAT so that date parsing can work with `std::str::FromStr