LibTimeZone: Parse and generate time zone coordinate data

This commit is contained in:
Timothy Flynn 2022-02-02 14:31:05 -05:00 committed by Andreas Kling
commit ea814a3ce6
Notes: sideshowbarker 2024-07-17 19:51:33 +09:00
4 changed files with 141 additions and 3 deletions

View file

@ -31,6 +31,22 @@ struct NamedOffset : public Offset {
String name;
};
struct Coordinate {
constexpr float decimal_coordinate() const
{
return static_cast<float>(degrees) + (static_cast<float>(minutes) / 60.0f) + (static_cast<float>(seconds) / 3'600.0f);
}
i16 degrees { 0 };
u8 minutes { 0 };
u8 seconds { 0 };
};
struct Location {
Coordinate latitude;
Coordinate longitude;
};
StringView system_time_zone();
StringView current_time_zone();
ErrorOr<void> change_time_zone(StringView time_zone);
@ -49,4 +65,7 @@ Optional<Offset> get_time_zone_offset(StringView time_zone, AK::Time time);
Optional<Array<NamedOffset, 2>> get_named_time_zone_offsets(TimeZone time_zone, AK::Time time);
Optional<Array<NamedOffset, 2>> get_named_time_zone_offsets(StringView time_zone, AK::Time time);
Optional<Location> get_time_zone_location(TimeZone time_zone);
Optional<Location> get_time_zone_location(StringView time_zone);
}