mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-21 10:40:01 +00:00
Compare commits
No commits in common. "e5d8f4386ce8b6f8e32738dc01428d1d8fbff9bb" and "77983eef777e9461723bb09838b20705716bbae5" have entirely different histories.
e5d8f4386c
...
77983eef77
@ -44,7 +44,7 @@ use chrono::NaiveDate;
|
||||
use rustframe::{
|
||||
frame::{Frame, RowIndex},
|
||||
matrix::{BoolOps, Matrix, SeriesOps},
|
||||
utils::{DateFreq, BDatesList},
|
||||
utils::{BDateFreq, BDatesList},
|
||||
};
|
||||
|
||||
let n_periods = 4;
|
||||
@ -53,7 +53,8 @@ let n_periods = 4;
|
||||
let dates: Vec<NaiveDate> =
|
||||
BDatesList::from_n_periods("2024-01-02".to_string(), BDateFreq::Daily, n_periods)
|
||||
.unwrap()
|
||||
.list().unwrap();
|
||||
.list()
|
||||
.unwrap();
|
||||
|
||||
let col_names: Vec<String> = vec!["a".to_string(), "b".to_string()];
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -565,7 +565,7 @@ impl Iterator for DatesGenerator {
|
||||
|
||||
/// Generates the flat list of dates for the given range and frequency.
|
||||
/// Assumes the `collect_*` functions return sorted dates.
|
||||
pub fn get_dates_list_with_freq(
|
||||
fn get_dates_list_with_freq(
|
||||
start_date_str: &str,
|
||||
end_date_str: &str,
|
||||
freq: DateFreq,
|
||||
@ -733,19 +733,6 @@ fn collect_quarterly(
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn get_dates_list_with_freq_from_naive_date(
|
||||
start_date: NaiveDate,
|
||||
end_date: NaiveDate,
|
||||
freq: DateFreq,
|
||||
) -> Result<Vec<NaiveDate>, Box<dyn Error>> {
|
||||
get_dates_list_with_freq(
|
||||
&start_date.format("%Y-%m-%d").to_string(),
|
||||
&end_date.format("%Y-%m-%d").to_string(),
|
||||
freq,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/// Return either the first or last calendar day in each year of the range.
|
||||
fn collect_yearly(
|
||||
start_date: NaiveDate,
|
||||
@ -832,7 +819,7 @@ fn last_day_of_month(year: i32, month: u32) -> Result<NaiveDate, Box<dyn Error>>
|
||||
|
||||
/// Converts a month number (1-12) to a quarter number (1-4).
|
||||
/// Panics if month is invalid (should not happen with valid NaiveDate).
|
||||
pub fn month_to_quarter(m: u32) -> u32 {
|
||||
fn month_to_quarter(m: u32) -> u32 {
|
||||
match m {
|
||||
1..=3 => 1,
|
||||
4..=6 => 2,
|
||||
@ -912,7 +899,7 @@ fn get_first_date_helper(freq: DateFreq) -> fn(i32, u32) -> Result<NaiveDate, Bo
|
||||
|
||||
/// Finds the *first* valid date according to the frequency,
|
||||
/// starting the search *on or after* the given `start_date`.
|
||||
pub fn find_first_date_on_or_after(
|
||||
fn find_first_date_on_or_after(
|
||||
start_date: NaiveDate,
|
||||
freq: DateFreq,
|
||||
) -> Result<NaiveDate, Box<dyn Error>> {
|
||||
@ -964,7 +951,7 @@ pub fn find_first_date_on_or_after(
|
||||
|
||||
/// Finds the *next* valid date according to the frequency,
|
||||
/// given the `current_date` (which is assumed to be a valid date previously generated).
|
||||
pub fn find_next_date(current_date: NaiveDate, freq: DateFreq) -> Result<NaiveDate, Box<dyn Error>> {
|
||||
fn find_next_date(current_date: NaiveDate, freq: DateFreq) -> Result<NaiveDate, Box<dyn Error>> {
|
||||
match freq {
|
||||
DateFreq::Daily => current_date
|
||||
.succ_opt()
|
||||
|
@ -1,8 +1,6 @@
|
||||
pub mod bdates;
|
||||
// pub use bdates::{BDateFreq, BDatesList, BDatesGenerator};
|
||||
pub use bdates::{BDateFreq, BDatesList, BDatesGenerator};
|
||||
|
||||
pub mod dates;
|
||||
// pub use dates::{DateFreq, DatesList, DatesGenerator};
|
||||
// pub mod base;
|
||||
// pub use base::{BDatesGenerator, BDatesList};
|
||||
// pub use base::{DateFreq, DatesGenerator, DatesList};
|
||||
pub use dates::{DateFreq, DatesList, DatesGenerator};
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
pub mod dateutils;
|
||||
pub use dateutils::bdates::{BDatesGenerator, BDatesList};
|
||||
pub use dateutils::dates::{DateFreq, DatesGenerator, DatesList};
|
||||
// pub use dateutils::{BDatesGenerator, BDatesList};
|
||||
// pub use dateutils::{DateFreq, DatesGenerator, DatesList};
|
||||
pub use dateutils::{BDateFreq, BDatesGenerator, BDatesList};
|
||||
pub use dateutils::{DateFreq, DatesGenerator, DatesList};
|
||||
|
Loading…
x
Reference in New Issue
Block a user