Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_function_date.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * afw_function_execute_* functions for Date
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 
18 /*
19  * Adaptive function: add_yearMonthDuration<date>
20  *
21  * afw_function_execute_add_yearMonthDuration_date
22  *
23  * See afw_function_bindings.h for more information.
24  *
25  * Add date arg1 to yearMonthDuration arg2 and return the date result.
26  *
27  * This function is pure, so it will always return the same result
28  * given exactly the same parameters and has no side effects.
29  *
30  * Declaration:
31  *
32  * ```
33  * function add_yearMonthDuration<date>(
34  * arg1: date,
35  * arg2: yearMonthDuration
36  * ): date;
37  * ```
38  *
39  * Parameters:
40  *
41  * arg1 - (date)
42  *
43  * arg2 - (yearMonthDuration)
44  *
45  * Returns:
46  *
47  * (date)
48  */
49 const afw_value_t *
52 {
53  const afw_value_date_t *arg1;
55  afw_value_date_t *result;
56 
59  2, yearMonthDuration);
60 
61  result = afw_value_allocate_date(x->p, x->xctx);
62  result->internal = arg1->internal;
63  afw_date_add_yearMonthDuration(&result->internal, &arg2->internal,
64  x->xctx);
65 
66  return (const afw_value_t *)result;
67 }
68 
69 
70 
71 /*
72  * Adaptive function: subtract_yearMonthDuration<date>
73  *
74  * afw_function_execute_subtract_yearMonthDuration_date
75  *
76  * See afw_function_bindings.h for more information.
77  *
78  * Subtract yearMonthDuration arg2 from date arg1 and return the date result.
79  *
80  * This function is pure, so it will always return the same result
81  * given exactly the same parameters and has no side effects.
82  *
83  * Declaration:
84  *
85  * ```
86  * function subtract_yearMonthDuration<date>(
87  * arg1: date,
88  * arg2: yearMonthDuration
89  * ): date;
90  * ```
91  *
92  * Parameters:
93  *
94  * arg1 - (date)
95  *
96  * arg2 - (yearMonthDuration)
97  *
98  * Returns:
99  *
100  * (date)
101  */
102 const afw_value_t *
105 {
106  const afw_value_date_t *arg1;
107  const afw_value_yearMonthDuration_t *arg2;
108  afw_value_date_t *result;
109 
112  yearMonthDuration);
113 
114  result = afw_value_allocate_date(x->p, x->xctx);
115  result->internal = arg1->internal;
116  afw_date_subtract_yearMonthDuration(&result->internal, &arg2->internal,
117  x->xctx);
118 
119  return (const afw_value_t *)result;
120 }
Adaptive Framework Core Internal.
afw_value_allocate_date(const afw_pool_t *p, afw_xctx_t *xctx)
Allocate function for unmanaged data type date value.
#define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
Definition: afw_function.h:328
const afw_value_t * afw_function_execute_add_yearMonthDuration_date(afw_function_execute_t *x)
Adaptive Function add_yearMonthDuration<date>
const afw_value_t * afw_function_execute_subtract_yearMonthDuration_date(afw_function_execute_t *x)
Adaptive Function subtract_yearMonthDuration<date>
afw_date_subtract_yearMonthDuration(afw_date_t *date, const afw_yearMonthDuration_t *yearMonthDuration, afw_xctx_t *xctx)
Subtract yearMonthDuration from date.
Definition: afw_time.c:1821
afw_date_add_yearMonthDuration(afw_date_t *date, const afw_yearMonthDuration_t *yearMonthDuration, afw_xctx_t *xctx)
Add yearMonthDuration to date.
Definition: afw_time.c:1791
Function execute parameter.
Definition: afw_function.h:53
afw_xctx_t * xctx
The execution context (xctx) of caller.
Definition: afw_function.h:62
const afw_pool_t * p
Pool for result.
Definition: afw_function.h:59
struct for data type date values.
Interface afw_value public struct.
struct for data type yearMonthDuration values.