mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 07:34:57 +00: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
7 changed files with 98 additions and 39 deletions
39
AK/DOSPackedTime.cpp
Normal file
39
AK/DOSPackedTime.cpp
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue