[orbis-kernel] +sys_utc_to_localtime, +sys_localtime_to_utc

This commit is contained in:
Ivan Chikish 2023-07-14 20:59:57 +03:00
parent 14b41d1af9
commit 0d7f50a246
3 changed files with 36 additions and 9 deletions

View file

@ -1,6 +1,7 @@
#include <array>
#include <orbis/error.hpp>
#include <orbis/thread.hpp>
#include <orbis/time.hpp>
namespace orbis {
using acl_type_t = sint;
@ -11,9 +12,6 @@ using cpuwhich_t = sint;
using cpulevel_t = sint;
using SceKernelModule = ModuleHandle;
struct timeval;
struct timezone;
struct ModuleInfo;
struct ModuleInfoEx;
struct KEvent;
@ -740,8 +738,11 @@ SysResult sys_thr_get_ucontext(Thread *thread /* TODO */);
SysResult sys_thr_set_ucontext(Thread *thread /* TODO */);
SysResult sys_set_timezone_info(Thread *thread /* TODO */);
SysResult sys_set_phys_fmem_limit(Thread *thread /* TODO */);
SysResult sys_utc_to_localtime(Thread *thread /* TODO */);
SysResult sys_localtime_to_utc(Thread *thread /* TODO */);
SysResult sys_utc_to_localtime(Thread *thread, int64_t time, int64_t *localtime,
orbis::timesec *_sec, int *_dst_sec);
SysResult sys_localtime_to_utc(Thread *thread, int64_t time, uint unk,
int64_t *ptime, orbis::timesec *_sec,
int *_dst_sec);
SysResult sys_set_uevt(Thread *thread /* TODO */);
SysResult sys_get_cpu_usage_proc(Thread *thread /* TODO */);
SysResult sys_get_map_statistics(Thread *thread /* TODO */);

View file

@ -15,4 +15,9 @@ struct timezone {
sint tz_minuteswest;
sint tz_dsttime;
};
struct timesec {
int64_t tz_time;
sint tz_secwest;
sint tz_dstsec;
};
} // namespace orbis

View file

@ -4,6 +4,7 @@
#include "evf.hpp"
#include "module/ModuleInfo.hpp"
#include "module/ModuleInfoEx.hpp"
#include "orbis/time.hpp"
#include "sys/sysproto.hpp"
#include "utils/Logs.hpp"
#include <chrono>
@ -852,11 +853,31 @@ orbis::SysResult orbis::sys_set_timezone_info(Thread *thread /* TODO */) {
orbis::SysResult orbis::sys_set_phys_fmem_limit(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_utc_to_localtime(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;
orbis::SysResult orbis::sys_utc_to_localtime(Thread *thread, int64_t time,
int64_t *localtime,
orbis::timesec *_sec,
int *_dst_sec) {
ORBIS_LOG_TRACE(__FUNCTION__, time, localtime, _sec, _dst_sec);
struct ::tm tp;
auto result = ::mktime(::localtime_r(&time, &tp));
if (auto e = uwrite(localtime, result); e != ErrorCode{})
return e;
uwrite(_sec, {});
uwrite(_dst_sec, 0);
return {};
}
orbis::SysResult orbis::sys_localtime_to_utc(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;
orbis::SysResult orbis::sys_localtime_to_utc(Thread *thread, int64_t time,
uint unk, int64_t *ptime,
orbis::timesec *_sec,
int *_dst_sec) {
ORBIS_LOG_TRACE(__FUNCTION__, time, unk, ptime, _sec, _dst_sec);
struct ::tm tp;
auto result = ::mktime(::gmtime_r(&time, &tp));
if (auto e = uwrite(ptime, result); e != ErrorCode{})
return e;
uwrite(_sec, {});
uwrite(_dst_sec, 0);
return {};
}
orbis::SysResult orbis::sys_set_uevt(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;