vitasdk
Documentation of the vitasdk
rtc.h
Go to the documentation of this file.
1 
7 #ifndef _PSP2_RTC_H_
8 #define _PSP2_RTC_H_
9 
10 #include <vitasdk/build_utils.h>
11 #include <psp2common/kernel/rtc.h>
12 #include <psp2/types.h>
13 #include <time.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 
20 unsigned int sceRtcGetTickResolution(void);
21 
22 
24 
33 int sceRtcGetCurrentClock(SceDateTime *time, int time_zone);
34 
43 
45 int sceRtcConvertUtcToLocalTime(const SceRtcTick *utc, SceRtcTick *local_time);
46 int sceRtcConvertLocalTimeToUtc(const SceRtcTick *local_time, SceRtcTick *utc);
47 int sceRtcIsLeapYear(int year);
49 int sceRtcGetDaysInMonth(int year, int month);
50 int sceRtcGetDayOfWeek(int year, int month, int day);
51 
52 /* Win/POSIX compliant function */
53 int sceRtcSetTime_t(SceDateTime *time, time_t iTime);
55 int sceRtcGetTime_t(const SceDateTime *time, time_t *piTime);
57 int sceRtcSetDosTime(SceDateTime *time, unsigned int uiDosTime);
58 int sceRtcGetDosTime(const SceDateTime *time, unsigned int *puiDosTime);
63 
64 /* Arithmetic function */
65 int sceRtcCompareTick(const SceRtcTick *pTick1, const SceRtcTick *pTick2);
66 int sceRtcTickAddTicks(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd);
67 int sceRtcTickAddMicroseconds(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd);
68 int sceRtcTickAddSeconds(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd);
69 int sceRtcTickAddMinutes(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd);
70 int sceRtcTickAddHours(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd);
71 int sceRtcTickAddDays(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd);
72 int sceRtcTickAddWeeks(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd);
73 int sceRtcTickAddMonths(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd);
74 int sceRtcTickAddYears(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd);
75 
76 /* Formating function */
77 int sceRtcFormatRFC2822(char *pszDateTime, const SceRtcTick *utc, int iTimeZoneMinutes);
78 int sceRtcFormatRFC2822LocalTime(char *pszDateTime, const SceRtcTick *utc);
79 int sceRtcFormatRFC3339(char *pszDateTime, const SceRtcTick *utc, int iTimeZoneMinutes);
80 int sceRtcFormatRFC3339LocalTime(char *pszDateTime, const SceRtcTick *utc);
81 int sceRtcParseDateTime(SceRtcTick *utc, const char *pszDateTime);
82 int sceRtcParseRFC3339(SceRtcTick *utc, const char *pszDateTime);
83 
84 /* Inline SceDateTime Getters */
85 
93 static inline int sceRtcGetYear(const SceDateTime *time){return time->year;}
94 
102 static inline int sceRtcGetMonth(const SceDateTime *time){return time->month;}
103 
111 static inline int sceRtcGetDay(const SceDateTime *time){return time->day;}
112 
120 static inline int sceRtcGetHour(const SceDateTime *time){return time->hour;}
121 
129 static inline int sceRtcGetMinute(const SceDateTime *time){return time->minute;}
130 
138 static inline int sceRtcGetSecond(const SceDateTime *time){return time->second;}
139 
147 static inline int sceRtcGetMicrosecond(const SceDateTime *time){return (int)time->microsecond;}
148 
149 /* Inline SceDateTime Setters */
150 static inline int sceRtcSetYear(SceDateTime *time, int year){
151  if (year<1 || year>9999)
153  time->year = (unsigned short)year;
154  return 0;
155 }
156 static inline int sceRtcSetMonth(SceDateTime *time, int month){
157  if (month<1 || month>12) {
159  }
160  time->month = (unsigned short)month;
161  return 0;
162 }
163 static inline int sceRtcSetDay(SceDateTime *time, int day){
164  if (day<1 || day>31) {
165  return (SCE_RTC_ERROR_INVALID_DAY);
166  }
167  time->day = (unsigned short)day;
168  return 0;
169 }
170 static inline int sceRtcSetHour(SceDateTime *time, int hour){
171  if (hour<0 || hour>23) {
173  }
174  time->hour = (unsigned short)hour;
175  return 0;
176 }
177 static inline int sceRtcSetMinute(SceDateTime *time, int minute){
178  if (minute<0 || minute>59) {
180  }
181  time->minute = (unsigned short)minute;
182  return 0;
183 }
184 static inline int sceRtcSetSecond(SceDateTime *time, int second){
185  if (second<0 || second>59) {
187  }
188  time->second = (unsigned short)second;
189  return 0;
190 }
191 static inline int sceRtcSetMicrosecond(SceDateTime *time, int microsecond){
192  if (microsecond<0 || microsecond>999999) {
194  }
195  time->microsecond = (unsigned int)microsecond;
196  return 0;
197 }
198 
199 /* Aliases */
200 #define sceRtcGetCurrentTickUtc(_tick) sceRtcGetCurrentTick(_tick)
201 #define sceRtcGetCurrentClockUtc(_p) sceRtcGetCurrentClock(_p,0)
202 #define sceRtcGetCurrentNetworkTickUtc(_tick) sceRtcGetCurrentNetworkTick(_tick)
203 #define sceRtcConvertTime_tToDateTime(_timet, _pdatetime) sceRtcSetTime_t(_pdatetime, _timet)
204 #define sceRtcConvertTime64_tToDateTime(_timet, _pdatetime) sceRtcSetTime64_t(_pdatetime, _timet)
205 #define sceRtcConvertDateTimeToTime_t(_pdatetime, _ptimet) sceRtcGetTime_t(_pdatetime, _ptimet)
206 #define sceRtcConvertDateTimeToTime64_t(_pdatetime, _ptimet) sceRtcGetTime64_t(_pdatetime, _ptimet)
207 #define sceRtcConvertDosTimeToDateTime(_dostime, _pdatetime) sceRtcSetDosTime(_pdatetime, _dostime)
208 #define sceRtcConvertDateTimeToDosTime(_pdatetime, _pdostime) sceRtcGetDosTime(_pdatetime, _pdostime)
209 #define sceRtcConvertWin32TimeToDateTime(_pw32time, _pdatetime) sceRtcSetWin32FileTime(_pdatetime, _pw32time)
210 #define sceRtcConvertDateTimeToWin32Time(_pdatetime, _pw32time) sceRtcGetWin32FileTime(_pdatetime, _pw32time)
211 #define sceRtcConvertTickToDateTime(_ptick, _pdatetime) sceRtcSetTick(_pdatetime, _ptick)
212 #define sceRtcConvertDateTimeToTick(_pdatetime, _ptick) sceRtcGetTick(_pdatetime, _ptick)
213 
223 
233 
244 int _sceRtcFormatRFC2822(char *datetime, const SceRtcTick *utc, int offset, SceUInt64 *a4);
245 
255 int _sceRtcFormatRFC2822LocalTime(char *datetime, const SceRtcTick *utc, SceUInt64 *a3);
256 
267 int _sceRtcFormatRFC3339(char *datetime, const SceRtcTick *utc, int offset, SceUInt64 *a4);
268 
278 int _sceRtcFormatRFC3339LocalTime(char *datetime, const SceRtcTick *utc, SceUInt64 *a3);
279 
287 
288 #ifdef __cplusplus
289 }
290 #endif
291 
292 #endif /* _PSP2_RTC_H_ */
293 
SceUInt64 time
Time of the event occurred.
Definition: debug.h:7
int sceRtcGetTick(const SceDateTime *time, SceRtcTick *tick)
int _sceRtcConvertUtcToLocalTime(const SceRtcTick *utc, SceRtcTick *localtime)
Convert UTC to localtime.
int _sceRtcFormatRFC2822LocalTime(char *datetime, const SceRtcTick *utc, SceUInt64 *a3)
Convert RFC2822 time string from UTC with localtime.
int sceRtcTickAddTicks(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd)
int sceRtcGetDayOfWeek(int year, int month, int day)
int sceRtcTickAddWeeks(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd)
int sceRtcSetWin32FileTime(SceDateTime *time, SceUInt64 ulWin32Time)
int sceRtcGetDosTime(const SceDateTime *time, unsigned int *puiDosTime)
int sceRtcGetCurrentAdNetworkTick(SceRtcTick *tick)
int sceRtcGetCurrentClockLocalTime(SceDateTime *time)
Get current real time clock time with system time zone.
int sceRtcFormatRFC3339(char *pszDateTime, const SceRtcTick *utc, int iTimeZoneMinutes)
int sceRtcGetCurrentClock(SceDateTime *time, int time_zone)
Get current real time clock time.
int sceRtcTickAddMinutes(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd)
int _sceRtcFormatRFC2822(char *datetime, const SceRtcTick *utc, int offset, SceUInt64 *a4)
Convert RFC2822 time string from UTC.
int sceRtcParseRFC3339(SceRtcTick *utc, const char *pszDateTime)
int sceRtcConvertLocalTimeToUtc(const SceRtcTick *local_time, SceRtcTick *utc)
int sceRtcFormatRFC3339LocalTime(char *pszDateTime, const SceRtcTick *utc)
int sceRtcTickAddSeconds(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd)
int sceRtcSetTick(SceDateTime *time, const SceRtcTick *tick)
int sceRtcSetDosTime(SceDateTime *time, unsigned int uiDosTime)
int sceRtcGetLastAdjustedTick(SceRtcTick *tick)
int sceRtcGetTime64_t(const SceDateTime *time, SceUInt64 *pullTime)
int sceRtcGetLastReincarnatedTick(SceRtcTick *tick)
int sceRtcParseDateTime(SceRtcTick *utc, const char *pszDateTime)
int _sceRtcFormatRFC3339(char *datetime, const SceRtcTick *utc, int offset, SceUInt64 *a4)
Convert RFC3339 time string from UTC.
int sceRtcFormatRFC2822LocalTime(char *pszDateTime, const SceRtcTick *utc)
int sceRtcTickAddDays(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd)
int sceRtcGetDaysInMonth(int year, int month)
int sceRtcGetCurrentRetainedNetworkTick(SceRtcTick *tick)
int sceRtcSetTime64_t(SceDateTime *time, SceUInt64 ullTime)
int sceRtcTickAddYears(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd)
int sceRtcIsLeapYear(int year)
int sceRtcGetCurrentTick(SceRtcTick *tick)
int sceRtcFormatRFC2822(char *pszDateTime, const SceRtcTick *utc, int iTimeZoneMinutes)
int sceRtcTickAddMonths(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd)
int sceRtcGetCurrentGpsTick(SceRtcTick *tick)
SceULong64 sceRtcGetAccumulativeTime(void)
int sceRtcConvertUtcToLocalTime(const SceRtcTick *utc, SceRtcTick *local_time)
int sceRtcTickAddHours(SceRtcTick *pTick0, const SceRtcTick *pTick1, int lAdd)
int _sceRtcConvertLocalTimeToUtc(const SceRtcTick *localtime, SceRtcTick *utc)
Convert localtime to UTC.
int sceRtcSetTime_t(SceDateTime *time, time_t iTime)
int sceRtcGetWin32FileTime(const SceDateTime *time, SceUInt64 *ulWin32Time)
unsigned int sceRtcGetTickResolution(void)
int sceRtcGetCurrentNetworkTick(SceRtcTick *tick)
int sceRtcTickAddMicroseconds(SceRtcTick *pTick0, const SceRtcTick *pTick1, SceLong64 lAdd)
int sceRtcGetTime_t(const SceDateTime *time, time_t *piTime)
int sceRtcCompareTick(const SceRtcTick *pTick1, const SceRtcTick *pTick2)
int sceRtcGetCurrentDebugNetworkTick(SceRtcTick *tick)
int sceRtcCheckValid(const SceDateTime *time)
int _sceRtcFormatRFC3339LocalTime(char *datetime, const SceRtcTick *utc, SceUInt64 *a3)
Convert RFC3339 time string from UTC with localtime.
@ SCE_RTC_ERROR_INVALID_DAY
Definition: rtc.h:27
@ SCE_RTC_ERROR_INVALID_HOUR
Definition: rtc.h:28
@ SCE_RTC_ERROR_INVALID_MONTH
Definition: rtc.h:26
@ SCE_RTC_ERROR_INVALID_MINUTE
Definition: rtc.h:29
@ SCE_RTC_ERROR_INVALID_SECOND
Definition: rtc.h:30
@ SCE_RTC_ERROR_INVALID_MICROSECOND
Definition: rtc.h:31
@ SCE_RTC_ERROR_INVALID_YEAR
Definition: rtc.h:25
Definition: rtc.h:48
int64_t SceLong64
Definition: types.h:53
uint64_t SceUInt64
Definition: types.h:51
uint64_t SceULong64
Definition: types.h:54
Definition: types.h:213