
--------------------------------------------------------------------------------
-- Date module
--------------------------------------------------------------------------------

---@class date_object*
local date_object = {}

---@class date*
---@field version integer Module version number, in the format major * 10000000 + minor * 10000 + revision
---@overload fun(): date_object*
---@overload fun(value: string|number|boolean|table|date_object*): date_object*
---@overload fun(year: number|string, month: number|string, day: number|string, hour?: number|string, min?: number|string, sec?: number|string, ticks?: number|string): date_object*
---@type date*
local M = {}

--- Construction time part
---@param hour? number time
---@param min? number points
---@param sec? number seconds
---@param ticks? number tick
---@return date_object* date date object
function M.time(hour, min, sec, ticks) end

--- Construct ISO week date
---@param year number year
---@param week? number week
---@param day? number ISO week
---@return date_object* date date object
function M.isodate(year, week, day) end

--- Determine leap year
---@param value number|date_object* year or date object
---@return boolean isLeap Is it a leap year?
function M.isleapyear(value) end

--- Get epoch date object
---@return date_object* date epoch
function M.epoch() end

--- Calculate the difference between two date objects
---@param lhs date_object* date object
---@param rhs date_object* date object
---@return date_object* diff Difference
function M.diff(lhs, rhs) end

--- Set or get the default format
---@param format? string Default format
---@return string format Default format
function M.fmt(format) end

--- Set century rollover threshold
---@param year integer threshold
function M.setcenturyflip(year) end

--- Get century rollover threshold
---@return integer year threshold
function M.getcenturyflip() end

--- Set or get the number of ticks per second
---@param ticks? integer ticks number
---@return integer ticks ticks per second
function M.ticks(ticks) end

--- Set or get the minimum daynum
---@param value? number daynum
---@return number|date_object* value daynum or date object
function M.daynummin(value) end

--- Set or get the maximum daynum
---@param value? number daynum
---@return number|date_object* value daynum or date object
function M.daynummax(value) end

--- Copy date object
---@return date_object* copy copy
function date_object:copy() end

--- Normalized date object
---@return date_object* self current object
function date_object:normalize() end

--- Get year, month and day
---@return integer year year
---@return integer month month
---@return integer day day
function date_object:getdate() end

--- Get hours, minutes, seconds and ticks
---@return integer hour time
---@return integer min points
---@return integer sec seconds
---@return number ticks tick
function date_object:gettime() end

--- Get year
---@return integer year year
function date_object:getyear() end

--- Get month
---@return integer month month
function date_object:getmonth() end

--- Get date
---@return integer day day
function date_object:getday() end

--- Get hours
---@return integer hour time
function date_object:gethours() end

--- Get the hour in 12-hour format
---@return integer hour 12 Hourly hour, range 1-12
function date_object:getclockhour() end

--- Get minutes
---@return integer min points
function date_object:getminutes() end

--- Get seconds
---@return integer sec seconds
function date_object:getseconds() end

--- Get fractional seconds
---@return number seconds fractional seconds
function date_object:getfracsec() end

--- Get ticks
---@param unit? number unit
---@return number ticks ticks
function date_object:getticks(unit) end

--- Get day of the week
---@return integer weekday Day of the week, Sunday is 1
function date_object:getweekday() end

--- Get the number of days in the year
---@return integer yearday days
function date_object:getyearday() end

--- Get week number
---@param weekBase? integer start day of week
---@return integer week Week number
function date_object:getweeknumber(weekBase) end

--- Get ISO weekday
---@return integer weekday ISO Day of the week, Monday is 1
function date_object:getisoweekday() end

--- Get ISO week number
---@return integer week ISO Week number
function date_object:getisoweeknumber() end

--- Get ISO year
---@return integer year ISO Year
function date_object:getisoyear() end

--- Get ISO date
---@return integer year ISO Year
---@return integer week ISO Week number
---@return integer weekday ISO week
function date_object:getisodate() end

--- Set year, month and day
---@param year? number year
---@param month? number month
---@param day? number day
---@return date_object* self current object
function date_object:setyear(year, month, day) end

--- Set ISO year, week and day of the week
---@param year? number ISO year
---@param week? number ISO week
---@param day? number ISO Day of the week, Monday is 1
---@return date_object* self current object
function date_object:setisoyear(year, week, day) end

--- Set ISO day of the week
---@param day number ISO Day of the week, Monday is 1
---@return date_object* self current object
function date_object:setisoweekday(day) end

--- Set ISO week number and optional day of week
---@param week number ISO week
---@param day? number ISO Day of the week, Monday is 1
---@return date_object* self current object
function date_object:setisoweeknumber(week, day) end

--- Set month
---@param month number month
---@param day? number day
---@return date_object* self current object
function date_object:setmonth(month, day) end

--- Set date
---@param day number day
---@return date_object* self current object
function date_object:setday(day) end

--- Set hours, minutes, seconds and ticks
---@param hour? number time
---@param min? number points
---@param sec? number seconds
---@param ticks? number tick
---@return date_object* self current object
function date_object:sethours(hour, min, sec, ticks) end

--- Set minutes
---@param min number points
---@param sec? number seconds
---@param ticks? number tick
---@return date_object* self current object
function date_object:setminutes(min, sec, ticks) end

--- Set seconds
---@param sec number seconds
---@param ticks? number tick
---@return date_object* self current object
function date_object:setseconds(sec, ticks) end

--- Set ticks
---@param ticks number tick
---@return date_object* self current object
function date_object:setticks(ticks) end

--- Add year, month and day
---@param years? number year
---@param months? number month
---@param days? number day
---@return date_object* self current object
function date_object:addyears(years, months, days) end

--- Add months and days
---@param months? number month
---@param days? number day
---@return date_object* self current object
function date_object:addmonths(months, days) end

--- Add days
---@param days number day
---@return date_object* self current object
function date_object:adddays(days) end

--- Add hours
---@param hours number hours
---@return date_object* self current object
function date_object:addhours(hours) end

--- Add minutes
---@param minutes number minutes
---@return date_object* self current object
function date_object:addminutes(minutes) end

--- add seconds
---@param seconds number seconds
---@return date_object* self current object
function date_object:addseconds(seconds) end

--- Add ticks
---@param ticks number tick
---@return date_object* self current object
function date_object:addticks(ticks) end

--- span ticks
---@return number ticks ticks
function date_object:spanticks() end

--- span seconds
---@return number seconds seconds
function date_object:spanseconds() end

--- span minutes
---@return number minutes minutes
function date_object:spanminutes() end

--- span hours
---@return number hours hours
function date_object:spanhours() end

--- span days
---@return number days day
function date_object:spandays() end

--- Convert to local time
---@return date_object*? self current object
function date_object:tolocal() end

--- Convert to UTC time
---@return date_object*? self current object
function date_object:toutc() end

--- Get time zone offset in minutes
---@return number bias Offset minutes
function date_object:getbias() end

--- Get time zone name
---@return string name time zone name
function date_object:gettzname() end

--- Output text according to format
---@param format? string Format
---@return string text Formatted text
function date_object:fmt(format) end

--- Output text in basic format
---@param format string Format
---@return string text Formatted text
function date_object:fmt0(format) end

return M
