DateTime.d.hpp (1582B)
1 #ifndef icu4x_DateTime_D_HPP 2 #define icu4x_DateTime_D_HPP 3 4 #include <stdio.h> 5 #include <stdint.h> 6 #include <stddef.h> 7 #include <stdbool.h> 8 #include <memory> 9 #include <functional> 10 #include <optional> 11 #include <cstdlib> 12 #include "../diplomat_runtime.hpp" 13 14 namespace icu4x { 15 namespace capi { struct Calendar; } 16 class Calendar; 17 namespace capi { struct Date; } 18 class Date; 19 namespace capi { struct Time; } 20 class Time; 21 struct DateTime; 22 class Rfc9557ParseError; 23 } 24 25 26 namespace icu4x { 27 namespace capi { 28 struct DateTime { 29 icu4x::capi::Date* date; 30 icu4x::capi::Time* time; 31 }; 32 33 typedef struct DateTime_option {union { DateTime ok; }; bool is_ok; } DateTime_option; 34 } // namespace capi 35 } // namespace 36 37 38 namespace icu4x { 39 /** 40 * An ICU4X DateTime object capable of containing a date and time for any calendar. 41 * 42 * See the [Rust documentation for `DateTime`](https://docs.rs/icu/latest/icu/time/struct.DateTime.html) for more information. 43 */ 44 struct DateTime { 45 std::unique_ptr<icu4x::Date> date; 46 std::unique_ptr<icu4x::Time> time; 47 48 /** 49 * Creates a new [`DateTime`] from an IXDTF string. 50 * 51 * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/time/struct.DateTime.html#method.try_from_str) for more information. 52 */ 53 inline static diplomat::result<icu4x::DateTime, icu4x::Rfc9557ParseError> from_string(std::string_view v, const icu4x::Calendar& calendar); 54 55 inline icu4x::capi::DateTime AsFFI() const; 56 inline static icu4x::DateTime FromFFI(icu4x::capi::DateTime c_struct); 57 }; 58 59 } // namespace 60 #endif // icu4x_DateTime_D_HPP