1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

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
parent 7b41a09540
commit ea814a3ce6
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);
}