Enhance utilities documentation with additional date and random number examples

This commit is contained in:
Palash Tyagi 2025-08-04 00:04:07 +01:00
parent 31a5ba2460
commit 039fb1a98e

View File

@ -3,16 +3,36 @@
Utilities provide handy helpers around the core library. Existing tools Utilities provide handy helpers around the core library. Existing tools
include: include:
- Date utilities for generating calendar sequences. - Date utilities for generating calendar sequences and businessday sets
- Random number generators for simulations and testing
## Date Helpers ## Date Helpers
```rust ```rust
# extern crate rustframe; # extern crate rustframe;
use rustframe::utils::dateutils::{DatesList, DateFreq}; use rustframe::utils::dateutils::{BDatesList, BDateFreq, DatesList, DateFreq};
// Calendar sequence
let list = DatesList::new("2024-01-01".into(), "2024-01-03".into(), DateFreq::Daily); let list = DatesList::new("2024-01-01".into(), "2024-01-03".into(), DateFreq::Daily);
assert_eq!(list.count().unwrap(), 3); assert_eq!(list.count().unwrap(), 3);
// Business days starting from 20240102
let bdates = BDatesList::from_n_periods("2024-01-02".into(), BDateFreq::Daily, 3).unwrap();
assert_eq!(bdates.list().unwrap().len(), 3);
```
## Random Numbers
The `random` module offers deterministic and cryptographically secure RNGs.
```rust
# extern crate rustframe;
use rustframe::random::{Prng, Rng};
let mut rng = Prng::new(42);
let v1 = rng.next_u64();
let v2 = rng.next_u64();
assert_ne!(v1, v2);
``` ```
Upcoming utilities will cover: Upcoming utilities will cover: