//
// Asura_Platform_Time_System.cpp
//
// Created by KOR - 15/09/2004
//
// Copyright (C) 2004 Rebellion, All Rights Reserved.
//

#include "Core/Asura.h"

// This file's header.
#include "Core/Asura_Time_System.h"

#include "Debugging/Asura_Assert.h"

#include <rtcsvc.h>
// need to link with library rtc_stub.a

void Asura_Time_System::Platform_GetCurrentDateAndTime()
{
	ScePspDateTime xDateAndTime;

	int iRet = sceRtcGetCurrentClockLocalTime(&xDateAndTime);
	Asura_Assert(iRet >= 0, "sceRtcGetCurrentClockLocalTime failed");
	if (iRet >= 0)
	{
		s_xTime.m_ucSecond = static_cast<u_char>(xDateAndTime.second);
		s_xTime.m_ucMinute = static_cast<u_char>(xDateAndTime.minute);
		s_xTime.m_ucHour = static_cast<u_char>(xDateAndTime.hour);
		s_xTime.m_ucDayOfMonth = static_cast<u_char>(xDateAndTime.day-1);	//Asura dates are zero-based.
		s_xTime.m_ucMonth = static_cast<u_char>(xDateAndTime.month-1);		
		s_xTime.m_usYear = static_cast<u_short>(xDateAndTime.year);

		s_xTime.m_ucDayOfWeek = static_cast<u_char>(GetDayOfWeek(s_xTime));
	}
}

// in minutes, where UTC = local time + bias 
int Asura_Time_System::Platform_GetTimeZoneBias()
{
	Asura_Assert(false, "not implemented");
	return 0;
}

void Asura_Time::Platform_FillFromLibCTime(u_int uLibCTime)
{
	Asura_Assert(false, "not implemented");
}
