1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! # shift-algorithm
//!
//! **Core shift scheduling algorithm.** The foundation of the entire 班伴 (ShiftMate) project.
//!
//! Given any date, this crate determines what shift a worker is on,
//! based on a repeating cycle shared across multiple teams.
//!
//! ## How it works
//!
//! The default cycle is 42 days, shared by 6 teams (一值~六值):
//!
//! ```text
//! 早 早 中 中 休 夜 夜 休 休 早 早 中 中 休 夜 休 休 休 早 早 中 休
//! 夜 夜 休 休 休 早 中 中 休 夜 夜 休 休 学 学 学 学 学 休 休
//! ```
//!
//! Each team is offset by 7 days (42 / 6). Reference date 2025-12-15 is day 1.
//! Team 1 starts at offset 0, team 2 at offset 7, etc.
//!
//! ## Quick start
//!
//! ```rust
//! use shift_algorithm::cycle::default_config;
//! use shift_algorithm::get_shift_info;
//! use chrono::NaiveDate;
//!
//! let config = default_config();
//! let today = NaiveDate::from_ymd_opt(2026, 5, 22).unwrap();
//! let info = get_shift_info(today, &config, 0);
//!
//! println!("{:?} · day {}/{}",
//! info.shift_type,
//! info.day_of_cycle,
//! config.cycle_length,
//! );
//! ```
//!
//! ## Crate structure
//!
//! - [`types`] — `ShiftType` enum, `ShiftInfo` struct, `ShiftCycleConfig`
//! - [`cycle`] — Default constants (42-day cycle, reference date, 6 teams)
//! - [`calculator`] — Pure functions: offset, normalize, get shift for date
pub use *;
pub use *;
pub use *;