mirror of
https://github.com/gorules/zen.git
synced 2026-10-05 00:02:26 +00:00
change set date signature
This commit is contained in:
@@ -115,7 +115,7 @@ impl From<&DateMethod> for Rc<dyn FunctionDefinition> {
|
||||
DM::Set => Rc::new(StaticFunction {
|
||||
implementation: Rc::new(imp::set),
|
||||
signature: FunctionSignature {
|
||||
parameters: vec![VT::Date, VT::Number, unit_vt.clone()],
|
||||
parameters: vec![VT::Date, unit_vt.clone(), VT::Number],
|
||||
return_type: VT::Date,
|
||||
},
|
||||
}),
|
||||
@@ -254,8 +254,8 @@ mod imp {
|
||||
|
||||
pub fn set(args: Arguments) -> anyhow::Result<V> {
|
||||
let this = args.dynamic::<VmDate>(0)?;
|
||||
let value = args.number(1)?;
|
||||
let unit = __internal_extract_duration_unit(&args, 2)?;
|
||||
let unit = __internal_extract_duration_unit(&args, 1)?;
|
||||
let value = args.number(2)?;
|
||||
|
||||
let value_u32 = value.to_u32().context("Invalid duration value")?;
|
||||
|
||||
|
||||
@@ -56,12 +56,12 @@ d('2000-10-15').isLeapYear();;true
|
||||
d('1900-10-15').isLeapYear();;false
|
||||
|
||||
# Date setters
|
||||
d('2023-10-15').set(2024, 'year');;'2024-10-15T00:00:00Z'
|
||||
d('2023-10-15').set(5, 'month');;'2023-05-15T00:00:00Z'
|
||||
d('2023-10-15').set(20, 'day');;'2023-10-20T00:00:00Z'
|
||||
d('2023-10-15T10:30:00Z').set(15, 'hour');;'2023-10-15T15:30:00Z'
|
||||
d('2023-10-15T10:30:00Z').set(45, 'minute');;'2023-10-15T10:45:00Z'
|
||||
d('2023-10-15T10:30:00Z').set(30, 'second');;'2023-10-15T10:30:30Z'
|
||||
d('2023-10-15').set('year', 2024);;'2024-10-15T00:00:00Z'
|
||||
d('2023-10-15').set('month', 5);;'2023-05-15T00:00:00Z'
|
||||
d('2023-10-15').set('day', 20);;'2023-10-20T00:00:00Z'
|
||||
d('2023-10-15T10:30:00Z').set('hour', 15);;'2023-10-15T15:30:00Z'
|
||||
d('2023-10-15T10:30:00Z').set('minute', 45);;'2023-10-15T10:45:00Z'
|
||||
d('2023-10-15T10:30:00Z').set('second', 30);;'2023-10-15T10:30:30Z'
|
||||
|
||||
# Special date checks
|
||||
d().isSame(d(), 'day');;true
|
||||
|
||||
|
Reference in New Issue
Block a user