2023-02-06 19:15:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Undefine <undefine@undefine.pl>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/DOSPackedTime.h>
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
2023-03-13 21:11:13 +00:00
|
|
|
UnixDateTime time_from_packed_dos(DOSPackedDate date, DOSPackedTime time)
|
2023-02-06 19:15:30 +00:00
|
|
|
{
|
|
|
|
if (date.value == 0)
|
2023-03-13 21:11:13 +00:00
|
|
|
return UnixDateTime::from_unix_time_parts(first_dos_year, 1, 1, 0, 0, 0, 0);
|
2023-02-06 19:15:30 +00:00
|
|
|
|
2023-03-13 21:11:13 +00:00
|
|
|
return UnixDateTime::from_unix_time_parts(first_dos_year + date.year, date.month, date.day, time.hour, time.minute, time.second * 2, 0);
|
2023-02-06 19:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|