ladybird/Libraries/LibUnicode/TimeZone.h
Andreas Kling b81269e78b Libraries: Clean up UTF-16 source text paths
Store parser errors, source range filenames, source code filenames,
module source, and Rust parser errors as UTF-16 where they flow back
into JavaScript-visible strings. Keep byte-oriented source buffers
byte-backed.

Remove temporary PrimitiveString, ByteString, and UTF-8 detours from
JSON, RegExp, module debug logging, print formatting, and tests.
2026-06-22 19:51:25 +02:00

64 lines
1.6 KiB
C++

/*
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Time.h>
#include <AK/Utf16String.h>
#include <AK/Utf16View.h>
#include <AK/Vector.h>
namespace Unicode {
struct TimeZoneOffset {
enum class InDST {
No,
Yes,
};
AK::Duration offset;
InDST in_dst { InDST::No };
};
struct TimeZoneTransition {
struct Options {
enum class Direction {
Previous,
Next,
};
enum class IncludeGivenTime {
No,
Yes,
};
enum class TransitionRule {
AnyTransition,
TransitionWhereUTCOffsetChanges,
};
Direction direction { Direction::Previous };
IncludeGivenTime include_given_time { IncludeGivenTime::No };
TransitionRule transition_rule { TransitionRule::AnyTransition };
};
AK::Duration transition;
};
Utf16String current_time_zone();
ErrorOr<void> set_current_time_zone(Utf16View);
void clear_system_time_zone_cache();
Vector<Utf16String> const& available_time_zones();
Vector<Utf16String> available_time_zones_in_region(Utf16View region);
Optional<Utf16String> resolve_primary_time_zone(Utf16View time_zone);
Optional<TimeZoneOffset> time_zone_offset(Utf16View time_zone, UnixDateTime time);
Vector<TimeZoneOffset> disambiguated_time_zone_offsets(Utf16View time_zone, UnixDateTime time);
Optional<TimeZoneTransition> get_time_zone_transition(Utf16View time_zone, UnixDateTime time, TimeZoneTransition::Options options);
}