diff options
author | Ollrogge <nils-ollrogge@outlook.de> | 2023-02-06 20:15:30 +0100 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2023-02-12 13:13:15 -0700 |
commit | 361df6eff8a650bcfbaf14bfe21ee5305c20e32c (patch) | |
tree | 3d338a1a592b3d9aaa0b4c4f65626f110fb96cc9 /AK/DOSPackedTime.cpp | |
parent | 7e915b145b5eb29520be27b84229aa4998274dc3 (diff) | |
download | serenity-361df6eff8a650bcfbaf14bfe21ee5305c20e32c.zip |
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.
Diffstat (limited to 'AK/DOSPackedTime.cpp')
-rw-r--r-- | AK/DOSPackedTime.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/AK/DOSPackedTime.cpp b/AK/DOSPackedTime.cpp new file mode 100644 index 0000000000..28d869f444 --- /dev/null +++ b/AK/DOSPackedTime.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022, Undefine <undefine@undefine.pl> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <AK/DOSPackedTime.h> + +namespace AK { + +Time time_from_packed_dos(DOSPackedDate date, DOSPackedTime time) +{ + if (date.value == 0) + return Time(); + + return Time::from_timestamp(first_dos_year + date.year, date.month, date.day, time.hour, time.minute, time.second * 2, 0); +} + +DOSPackedDate to_packed_dos_date(unsigned year, unsigned month, unsigned day) +{ + DOSPackedDate date; + date.year = year - first_dos_year; + date.month = month; + date.day = day; + + return date; +} + +DOSPackedTime to_packed_dos_time(unsigned hour, unsigned minute, unsigned second) +{ + DOSPackedTime time; + time.hour = hour; + time.minute = minute; + time.second = second / 2; + + return time; +} + +} |