rl_lang/interpreter/stdlib/time/
time_parts.rs1use crate::{
2 ast::statements::TypeAnnotation,
3 interpreter::{
4 evaluator::Evaluator,
5 stdlib::{
6 common::{verr, vi, vok, vs},
7 time::format_time::unix_to_parts,
8 },
9 values::Value,
10 },
11};
12
13pub fn time_parts(_: &mut Evaluator, timestamp: i64) -> Value {
14 if timestamp < 0 {
15 return verr!(vs!("timestamp is negative".to_string()));
16 }
17
18 let (year, month, day, hour, minute, second) = unix_to_parts(timestamp);
19 vok!(Value::Values {
20 items_type: TypeAnnotation::Int,
21 items: vec![
22 vi!(year as i64),
23 vi!(month as i64),
24 vi!(day as i64),
25 vi!(hour as i64),
26 vi!(minute as i64),
27 vi!(second as i64),
28 ],
29 })
30}