This repository has been archived on 2026-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
sdl3bindings2/official/release-3.2.26/tmp/time.zig

64 lines
2.0 KiB
Zig

const std = @import("std");
pub const c = @import("c.zig").c;
pub const Time = i64;
pub const DateTime = extern struct {
year: c_int, // Year
month: c_int, // Month [01-12]
day: c_int, // Day of the month [01-31]
hour: c_int, // Hour [0-23]
minute: c_int, // Minute [0-59]
second: c_int, // Seconds [0-60]
nanosecond: c_int, // Nanoseconds [0-999999999]
day_of_week: c_int, // Day of the week [0-6] (0 being Sunday)
utc_offset: c_int, // Seconds east of UTC
};
pub const DateFormat = enum(c_int) {
dateFormatYyyymmdd, //Year/Month/Day
dateFormatDdmmyyyy, //Day/Month/Year
dateFormatMmddyyyy, //Month/Day/Year
};
pub const TimeFormat = enum(c_int) {
timeFormat24hr, //24 hour time
timeFormat12hr, //12 hour time
};
pub inline fn getDateTimeLocalePreferences(dateFormat: ?*DateFormat, timeFormat: ?*TimeFormat) bool {
return c.SDL_GetDateTimeLocalePreferences(@bitCast(dateFormat), @bitCast(timeFormat));
}
pub inline fn getCurrentTime(ticks: ?*Time) bool {
return c.SDL_GetCurrentTime(ticks);
}
pub inline fn timeToDateTime(ticks: Time, dt: ?*DateTime, localTime: bool) bool {
return c.SDL_TimeToDateTime(ticks, dt, localTime);
}
pub inline fn dateTimeToTime(dt: *const DateTime, ticks: ?*Time) bool {
return c.SDL_DateTimeToTime(@ptrCast(dt), ticks);
}
pub inline fn timeToWindows(ticks: Time, dwLowDateTime: *u32, dwHighDateTime: *u32) void {
return c.SDL_TimeToWindows(ticks, @ptrCast(dwLowDateTime), @ptrCast(dwHighDateTime));
}
pub inline fn timeFromWindows(dwLowDateTime: u32, dwHighDateTime: u32) Time {
return c.SDL_TimeFromWindows(dwLowDateTime, dwHighDateTime);
}
pub inline fn getDaysInMonth(year: c_int, month: c_int) c_int {
return c.SDL_GetDaysInMonth(year, month);
}
pub inline fn getDayOfYear(year: c_int, month: c_int, day: c_int) c_int {
return c.SDL_GetDayOfYear(year, month, day);
}
pub inline fn getDayOfWeek(year: c_int, month: c_int, day: c_int) c_int {
return c.SDL_GetDayOfWeek(year, month, day);
}