mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibTimeZone: Use new AK::Time factory method in generated code
This commit is contained in:
parent
2b5840296a
commit
5aa144193c
1 changed files with 1 additions and 12 deletions
|
@ -267,22 +267,11 @@ static void generate_time_zone_data_implementation(Core::File& file, TimeZoneDat
|
||||||
|
|
||||||
namespace TimeZone {
|
namespace TimeZone {
|
||||||
|
|
||||||
static constexpr auto seconds_per_day = 86'400;
|
|
||||||
static constexpr auto seconds_per_hour = 3'600;
|
|
||||||
static constexpr auto seconds_per_minute = 60;
|
|
||||||
|
|
||||||
struct DateTime {
|
struct DateTime {
|
||||||
AK::Time time_since_epoch() const
|
AK::Time time_since_epoch() const
|
||||||
{
|
{
|
||||||
// FIXME: This implementation does not take last_weekday or after_weekday into account.
|
// FIXME: This implementation does not take last_weekday or after_weekday into account.
|
||||||
i64 seconds_since_epoch = AK::days_since_epoch(year, month, day);
|
return AK::Time::from_timestamp(year, month, day, hour, minute, second, 0);
|
||||||
seconds_since_epoch *= seconds_per_day;
|
|
||||||
|
|
||||||
seconds_since_epoch += hour * seconds_per_hour;
|
|
||||||
seconds_since_epoch += minute * seconds_per_minute;
|
|
||||||
seconds_since_epoch += second;
|
|
||||||
|
|
||||||
return AK::Time::from_seconds(seconds_since_epoch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 year { 0 };
|
u16 year { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue