A basic utilities to convert tick number to a date time to use in game. It was first made to fulfill the need of city building games.
It is divided into three main calendar types, an Earthlike lunar calendar, Earthlike real calendar and Custom calendar where you decide the value of each units.
```rust // Initialize a lunar ticktime where one tick is 3600 seconds let mut ticktime = TickTime::init( 0,TickTimeType::EarthLike { secondspertick: 3600, month_type: EarthLikeMonthType::Lunar }).unwrap();
// Calling tick to simulate 40 days
for _ in 0..(24*40) {
ticktime.tick();
}
println!("{}", ticktime.to_string()); // Month 1, Day 10
```
```rust // Initialize a real ticktime where one tick is 3600 seconds let mut ticktime = TickTime::init( 0,TickTimeType::EarthLike { secondspertick: 3600, month_type: EarthLikeMonthType::Real }).unwrap();
// Calling tick to simulate 40 days
for _ in 0..(24*40) {
ticktime.tick();
}
println!("{}", ticktime.to_string()); // Month 1, Day 9
```
```rust // Initialize a custom ticktime where one tick is 3600 seconds // where each day is 12 hours long // and year are composed of 4 months with 1 day let mut ticktime = TickTime::init( 0,TickTimeType::Custom { secondspertick: 3600, hoursinaday: 12, monthsdurations: vec![1, 1, 1, 1], seasonduration: vec![4], weekduration: 7 } ).unwrap();
// Calling tick to simulate 40 days
for _ in 0..(24*40) {
ticktime.tick();
}
println!("{}", ticktime.to_string()); // Year 20, Month 0, Day 0
```