mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
LibTimeZone: Parse and generate time zone coordinate data
This commit is contained in:
parent
7b41a09540
commit
ea814a3ce6
4 changed files with 141 additions and 3 deletions
|
@ -183,4 +183,13 @@ Optional<Array<NamedOffset, 2>> get_named_time_zone_offsets(StringView time_zone
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Location> __attribute__((weak)) get_time_zone_location(TimeZone) { return {}; }
|
||||
|
||||
Optional<Location> get_time_zone_location(StringView time_zone)
|
||||
{
|
||||
if (auto maybe_time_zone = time_zone_from_string(time_zone); maybe_time_zone.has_value())
|
||||
return get_time_zone_location(*maybe_time_zone);
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue