MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / sub_op

Method sub_op

crates/gitql-core/src/values/date.rs:62–69  ·  view source on GitHub ↗
(&self, other: &Box<dyn Value>)

Source from the content-addressed store, hash-verified

60 }
61
62 fn sub_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
63 if let Some(days) = other.as_int() {
64 let days_to_timestamp = days * 24 * 60 * 60;
65 let timestamp = self.timestamp - days_to_timestamp;
66 return Ok(Box::new(DateValue::new(timestamp)));
67 }
68 Err("Unexpected type to perform `-` with".to_string())
69 }
70
71 fn eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
72 if let Some(other_text) = other.as_any().downcast_ref::<DateValue>() {

Callers 1

evaluate_arithmeticFunction · 0.45

Calls 1

as_intMethod · 0.80

Tested by

no test coverage detected