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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (C) 2020 - 2022, J2 Innovations
//!
//! C API for working with the [Date](crate::val::Date) type.
//!
use Datelike;
use new_error;
use crateValue;
/// Get the year of a [Date](crate::val::Date) [Value](crate::val::Value)
/// # Arguments
/// val A [Date](crate::val::Date) [Value](crate::val::Value)
/// # Returns
/// - value
/// - -1 (u32::MAX) if there was an error
/// # Example
/// ```rust
/// # use crate::libhaystack::val::Value;
/// # use crate::libhaystack::c_api::value::*;
/// # use crate::libhaystack::c_api::date::*;
/// # unsafe {
/// let val = haystack_value_make_date(2021, 8, 13);
/// # let val = Box::<Value>::leak(val.unwrap());
/// assert!(haystack_value_is_date(val));
/// assert_eq!(haystack_value_get_date_year(val), 2021);
/// # }
/// ```
/// # Safety
/// Panics on invalid input data
pub unsafe extern "C"
/// Get the month of a [Date](crate::val::Date) [Value](crate::val::Value)
/// # Arguments
/// val A [Date](crate::val::Date) [Value](crate::val::Value)
/// # Returns
/// - value
/// - -1 (u32::MAX) if there was an error
/// # Example
/// ```rust
/// # use crate::libhaystack::val::Value;
/// # use crate::libhaystack::c_api::value::*;
/// # use crate::libhaystack::c_api::date::*;
/// # unsafe {
/// let val = haystack_value_make_date(2021, 8, 13);
/// # let val = Box::<Value>::leak(val.unwrap());
/// assert!(haystack_value_is_date(val));
/// assert_eq!(haystack_value_get_date_month(val), 8);
/// # }
/// ```
/// # Safety
/// Panics on invalid input data
pub unsafe extern "C"
/// Get the day of a [Date](crate::val::Date) [Value](crate::val::Value)
/// # Arguments
/// val A [Date](crate::val::Date) [Value](crate::val::Value)
/// # Returns
/// - value
/// - -1 (u32::MAX) if there was an error
/// # Example
/// ```rust
/// # use crate::libhaystack::val::Value;
/// # use crate::libhaystack::c_api::value::*;
/// # use crate::libhaystack::c_api::date::*;
/// # unsafe {
/// let val = haystack_value_make_date(2021, 8, 13);
/// # let val = Box::<Value>::leak(val.unwrap());
/// assert!(haystack_value_is_date(val));
/// assert_eq!(haystack_value_get_date_day(val), 13);
/// # }
/// ```
/// # Safety
/// Panics on invalid input data
pub unsafe extern "C"