mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
AK: Add conversion functions for packed DOS time format
This also adjusts the FATFS code to use the new functions and removes the now redundant old conversion functions.
This commit is contained in:
parent
7e915b145b
commit
361df6eff8
Notes:
sideshowbarker
2024-07-17 10:10:18 +09:00
Author: https://github.com/Ollrogge
Commit: 361df6eff8
Pull-request: https://github.com/SerenityOS/serenity/pull/17224
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/drunderscore
Reviewed-by: https://github.com/timschumi
7 changed files with 98 additions and 39 deletions
48
AK/DOSPackedTime.h
Normal file
48
AK/DOSPackedTime.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Undefine <undefine@undefine.pl>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
union DOSPackedTime {
|
||||
u16 value;
|
||||
struct {
|
||||
u16 second : 5;
|
||||
u16 minute : 6;
|
||||
u16 hour : 5;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(DOSPackedTime) == 2);
|
||||
|
||||
union DOSPackedDate {
|
||||
u16 value;
|
||||
struct {
|
||||
u16 day : 5;
|
||||
u16 month : 4;
|
||||
u16 year : 7;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(DOSPackedDate) == 2);
|
||||
|
||||
inline constexpr u16 first_dos_year = 1980;
|
||||
|
||||
Time time_from_packed_dos(DOSPackedDate, DOSPackedTime);
|
||||
DOSPackedDate to_packed_dos_date(unsigned year, unsigned month, unsigned day);
|
||||
DOSPackedTime to_packed_dos_time(unsigned hour, unsigned minute, unsigned second);
|
||||
|
||||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
using AK::DOSPackedDate;
|
||||
using AK::DOSPackedTime;
|
||||
using AK::time_from_packed_dos;
|
||||
using AK::to_packed_dos_date;
|
||||
using AK::to_packed_dos_time;
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue