1 | #include "icutil.hpp" |
---|
2 | #include "icdate.hpp" |
---|
3 | #include "calendar_util.hpp" |
---|
4 | |
---|
5 | extern "C" |
---|
6 | { |
---|
7 | void cxios_duration_convert_to_string(cxios_duration dur_c, char* str, int str_size) |
---|
8 | { |
---|
9 | xios::CDuration dur = { dur_c.year, dur_c.month, dur_c.day, |
---|
10 | dur_c.hour, dur_c.minute, dur_c.second, |
---|
11 | dur_c.timestep }; |
---|
12 | |
---|
13 | if (!string_copy(dur.toString(), str, str_size)) |
---|
14 | ERROR("void cxios_duration_convert_to_string(cxios_duration dur_c, char* str, int str_size)", << "Input string is too short"); |
---|
15 | } |
---|
16 | |
---|
17 | cxios_duration cxios_duration_add(cxios_duration dur1_c, cxios_duration dur2_c) |
---|
18 | { |
---|
19 | xios::CDuration dur1 = { dur1_c.year, dur1_c.month, dur1_c.day, |
---|
20 | dur1_c.hour, dur1_c.minute, dur1_c.second, |
---|
21 | dur1_c.timestep }; |
---|
22 | xios::CDuration dur2 = { dur2_c.year, dur2_c.month, dur2_c.day, |
---|
23 | dur2_c.hour, dur2_c.minute, dur2_c.second, |
---|
24 | dur2_c.timestep }; |
---|
25 | xios::CDuration res = dur1 + dur2; |
---|
26 | return { res.year, res.month, res.day, res.hour, res.minute, res.second, res.timestep }; |
---|
27 | } |
---|
28 | |
---|
29 | cxios_duration cxios_duration_sub(cxios_duration dur1_c, cxios_duration dur2_c) |
---|
30 | { |
---|
31 | xios::CDuration dur1 = { dur1_c.year, dur1_c.month, dur1_c.day, |
---|
32 | dur1_c.hour, dur1_c.minute, dur1_c.second, |
---|
33 | dur1_c.timestep }; |
---|
34 | xios::CDuration dur2 = { dur2_c.year, dur2_c.month, dur2_c.day, |
---|
35 | dur2_c.hour, dur2_c.minute, dur2_c.second, |
---|
36 | dur2_c.timestep }; |
---|
37 | xios::CDuration res = dur1 - dur2; |
---|
38 | return { res.year, res.month, res.day, res.hour, res.minute, res.second, res.timestep }; |
---|
39 | } |
---|
40 | |
---|
41 | cxios_duration cxios_duration_mult(double val, cxios_duration dur_c) |
---|
42 | { |
---|
43 | xios::CDuration dur = { dur_c.year, dur_c.month, dur_c.day, |
---|
44 | dur_c.hour, dur_c.minute, dur_c.second, |
---|
45 | dur_c.timestep }; |
---|
46 | xios::CDuration res = val * dur; |
---|
47 | return { res.year, res.month, res.day, res.hour, res.minute, res.second, res.timestep }; |
---|
48 | } |
---|
49 | |
---|
50 | cxios_duration cxios_duration_neg(cxios_duration dur_c) |
---|
51 | { |
---|
52 | xios::CDuration dur = { dur_c.year, dur_c.month, dur_c.day, |
---|
53 | dur_c.hour, dur_c.minute, dur_c.second, |
---|
54 | dur_c.timestep }; |
---|
55 | xios::CDuration res = -dur; |
---|
56 | return { res.year, res.month, res.day, res.hour, res.minute, res.second, res.timestep }; |
---|
57 | } |
---|
58 | |
---|
59 | bool cxios_duration_eq(cxios_duration dur1_c, cxios_duration dur2_c) |
---|
60 | { |
---|
61 | xios::CDuration dur1 = { dur1_c.year, dur1_c.month, dur1_c.day, |
---|
62 | dur1_c.hour, dur1_c.minute, dur1_c.second, |
---|
63 | dur1_c.timestep }; |
---|
64 | xios::CDuration dur2 = { dur2_c.year, dur2_c.month, dur2_c.day, |
---|
65 | dur2_c.hour, dur2_c.minute, dur2_c.second, |
---|
66 | dur2_c.timestep }; |
---|
67 | return (dur1 == dur2); |
---|
68 | } |
---|
69 | |
---|
70 | bool cxios_duration_neq(cxios_duration dur1_c, cxios_duration dur2_c) |
---|
71 | { |
---|
72 | xios::CDuration dur1 = { dur1_c.year, dur1_c.month, dur1_c.day, |
---|
73 | dur1_c.hour, dur1_c.minute, dur1_c.second, |
---|
74 | dur1_c.timestep }; |
---|
75 | xios::CDuration dur2 = { dur2_c.year, dur2_c.month, dur2_c.day, |
---|
76 | dur2_c.hour, dur2_c.minute, dur2_c.second, |
---|
77 | dur2_c.timestep }; |
---|
78 | return (dur1 != dur2); |
---|
79 | } |
---|
80 | } |
---|