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 = 0, //Year/Month/Day
    dateFormatDdmmyyyy = 1, //Day/Month/Year
    dateFormatMmddyyyy = 2, //Month/Day/Year
};

pub const TimeFormat = enum(c_int) {
    timeFormat24hr = 0, //24 hour time
    timeFormat12hr = 1, //12 hour time
};

pub inline fn getDateTimeLocalePreferences(dateFormat: ?*DateFormat, timeFormat: ?*TimeFormat) bool {
    return @bitCast(c.SDL_GetDateTimeLocalePreferences(@bitCast(dateFormat), @bitCast(timeFormat)));
}

pub inline fn getCurrentTime(ticks: ?*Time) bool {
    return @bitCast(c.SDL_GetCurrentTime(ticks));
}

pub inline fn timeToDateTime(ticks: Time, dt: ?*DateTime, localTime: bool) bool {
    return @bitCast(c.SDL_TimeToDateTime(ticks, dt, @bitCast(localTime)));
}

pub inline fn dateTimeToTime(dt: *const DateTime, ticks: ?*Time) bool {
    return @bitCast(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);
}
