mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
Run stylua
This commit is contained in:
parent
6b45f44d1f
commit
b1d60d904c
7 changed files with 96 additions and 22 deletions
|
@ -4,9 +4,27 @@ local values = DateTime.fromRfc3339("2023-08-27T05:54:19Z"):toLocalTime()
|
||||||
|
|
||||||
local expectedDateTimeValues = os.date("*t", 1693115659)
|
local expectedDateTimeValues = os.date("*t", 1693115659)
|
||||||
|
|
||||||
assert(values.year == expectedDateTimeValues.year, `expected {values.year} == {expectedDateTimeValues.year}`)
|
assert(
|
||||||
assert(values.month == expectedDateTimeValues.month, `expected {values.month} == {expectedDateTimeValues.month}`)
|
values.year == expectedDateTimeValues.year,
|
||||||
assert(values.day == expectedDateTimeValues.day, `expected {values.day} == {expectedDateTimeValues.day}`)
|
`expected {values.year} == {expectedDateTimeValues.year}`
|
||||||
assert(values.hour == expectedDateTimeValues.hour, `expected {values.hour} == {expectedDateTimeValues.hour}`)
|
)
|
||||||
assert(values.minute == expectedDateTimeValues.min, `expected {values.minute} == {expectedDateTimeValues.min}`)
|
assert(
|
||||||
assert(values.second == expectedDateTimeValues.sec, `expected {values.second} == {expectedDateTimeValues.sec}`)
|
values.month == expectedDateTimeValues.month,
|
||||||
|
`expected {values.month} == {expectedDateTimeValues.month}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.day == expectedDateTimeValues.day,
|
||||||
|
`expected {values.day} == {expectedDateTimeValues.day}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.hour == expectedDateTimeValues.hour,
|
||||||
|
`expected {values.hour} == {expectedDateTimeValues.hour}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.minute == expectedDateTimeValues.min,
|
||||||
|
`expected {values.minute} == {expectedDateTimeValues.min}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.second == expectedDateTimeValues.sec,
|
||||||
|
`expected {values.second} == {expectedDateTimeValues.sec}`
|
||||||
|
)
|
||||||
|
|
|
@ -10,14 +10,23 @@ local timezoneSplitIdx = string.find(nowRfc, "+")
|
||||||
local timezoneZeroedIdx = string.find(nowRfc, "Z")
|
local timezoneZeroedIdx = string.find(nowRfc, "Z")
|
||||||
|
|
||||||
assert(dateTimeSplitIdx ~= nil, "Missing date & time separator 'T' in RFC 3339 string")
|
assert(dateTimeSplitIdx ~= nil, "Missing date & time separator 'T' in RFC 3339 string")
|
||||||
assert(timezoneSplitIdx ~= nil or timezoneZeroedIdx ~= nil, "Missing timezone separator '+' or 'Z' in RFC 3339 string")
|
assert(
|
||||||
|
timezoneSplitIdx ~= nil or timezoneZeroedIdx ~= nil,
|
||||||
|
"Missing timezone separator '+' or 'Z' in RFC 3339 string"
|
||||||
|
)
|
||||||
|
|
||||||
-- Split date (before T) by dashes, split time (after T, before + or Z)
|
-- Split date (before T) by dashes, split time (after T, before + or Z)
|
||||||
-- by colons, we should then get 3 substrings for each of date & time
|
-- by colons, we should then get 3 substrings for each of date & time
|
||||||
|
|
||||||
local dateParts = string.split(string.sub(nowRfc, 1, dateTimeSplitIdx - 1), "-")
|
local dateParts = string.split(string.sub(nowRfc, 1, dateTimeSplitIdx - 1), "-")
|
||||||
local timeParts =
|
local timeParts = string.split(
|
||||||
string.split(string.sub(nowRfc, dateTimeSplitIdx + 1, ((timezoneSplitIdx or timezoneZeroedIdx) :: number) - 1), ":")
|
string.sub(
|
||||||
|
nowRfc,
|
||||||
|
dateTimeSplitIdx + 1,
|
||||||
|
((timezoneSplitIdx or timezoneZeroedIdx) :: number) - 1
|
||||||
|
),
|
||||||
|
":"
|
||||||
|
)
|
||||||
|
|
||||||
assert(#dateParts == 3, "Date partial of RFC 3339 should consist of 3 substrings, separated by '-'")
|
assert(#dateParts == 3, "Date partial of RFC 3339 should consist of 3 substrings, separated by '-'")
|
||||||
assert(#timeParts == 3, "Time partial of RFC 3339 should consist of 3 substrings, separated by ':'")
|
assert(#timeParts == 3, "Time partial of RFC 3339 should consist of 3 substrings, separated by ':'")
|
||||||
|
@ -42,13 +51,22 @@ assert(
|
||||||
|
|
||||||
if timezoneZeroedIdx ~= nil then
|
if timezoneZeroedIdx ~= nil then
|
||||||
-- No timezone offset
|
-- No timezone offset
|
||||||
assert(timezoneZeroedIdx == #nowRfc, "Timezone specifier 'Z' must be at the last character in RFC 3339 string")
|
assert(
|
||||||
|
timezoneZeroedIdx == #nowRfc,
|
||||||
|
"Timezone specifier 'Z' must be at the last character in RFC 3339 string"
|
||||||
|
)
|
||||||
elseif timezoneSplitIdx ~= nil then
|
elseif timezoneSplitIdx ~= nil then
|
||||||
-- Timezone offset
|
-- Timezone offset
|
||||||
local timezoneParts = string.split(string.sub(nowRfc, timezoneSplitIdx + 1), ":")
|
local timezoneParts = string.split(string.sub(nowRfc, timezoneSplitIdx + 1), ":")
|
||||||
assert(#timezoneParts == 2, "Timezone partial should consist of 2 substings, separated by ':'")
|
assert(#timezoneParts == 2, "Timezone partial should consist of 2 substings, separated by ':'")
|
||||||
assert(string.match(timezoneParts[1], "^%d%d$"), "Timezone partial should have 2 digits for hour")
|
assert(
|
||||||
assert(string.match(timezoneParts[2], "^%d%d$"), "Timezone partial should have 2 digits for minute")
|
string.match(timezoneParts[1], "^%d%d$"),
|
||||||
|
"Timezone partial should have 2 digits for hour"
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
string.match(timezoneParts[2], "^%d%d$"),
|
||||||
|
"Timezone partial should have 2 digits for minute"
|
||||||
|
)
|
||||||
else
|
else
|
||||||
error("unreachable")
|
error("unreachable")
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,27 @@ local values = DateTime.fromRfc3339("2023-08-27T05:54:19Z"):toLocalTime()
|
||||||
|
|
||||||
local expectedDateTimeValues = os.date("*t", 1693115659)
|
local expectedDateTimeValues = os.date("*t", 1693115659)
|
||||||
|
|
||||||
assert(values.year == expectedDateTimeValues.year, `expected {values.year} == {expectedDateTimeValues.year}`)
|
assert(
|
||||||
assert(values.month == expectedDateTimeValues.month, `expected {values.month} == {expectedDateTimeValues.month}`)
|
values.year == expectedDateTimeValues.year,
|
||||||
assert(values.day == expectedDateTimeValues.day, `expected {values.day} == {expectedDateTimeValues.day}`)
|
`expected {values.year} == {expectedDateTimeValues.year}`
|
||||||
assert(values.hour == expectedDateTimeValues.hour, `expected {values.hour} == {expectedDateTimeValues.hour}`)
|
)
|
||||||
assert(values.minute == expectedDateTimeValues.min, `expected {values.minute} == {expectedDateTimeValues.min}`)
|
assert(
|
||||||
assert(values.second == expectedDateTimeValues.sec, `expected {values.second} == {expectedDateTimeValues.sec}`)
|
values.month == expectedDateTimeValues.month,
|
||||||
|
`expected {values.month} == {expectedDateTimeValues.month}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.day == expectedDateTimeValues.day,
|
||||||
|
`expected {values.day} == {expectedDateTimeValues.day}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.hour == expectedDateTimeValues.hour,
|
||||||
|
`expected {values.hour} == {expectedDateTimeValues.hour}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.minute == expectedDateTimeValues.min,
|
||||||
|
`expected {values.minute} == {expectedDateTimeValues.min}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
values.second == expectedDateTimeValues.sec,
|
||||||
|
`expected {values.second} == {expectedDateTimeValues.sec}`
|
||||||
|
)
|
||||||
|
|
|
@ -5,4 +5,7 @@ local childThread = coroutine.create(process.create)
|
||||||
local ok, err = coroutine.resume(childThread, "echo", { "hello, world" })
|
local ok, err = coroutine.resume(childThread, "echo", { "hello, world" })
|
||||||
assert(ok, err)
|
assert(ok, err)
|
||||||
|
|
||||||
assert(coroutine.status(childThread) == "dead", "Child process should not yield the thread it is created on")
|
assert(
|
||||||
|
coroutine.status(childThread) == "dead",
|
||||||
|
"Child process should not yield the thread it is created on"
|
||||||
|
)
|
||||||
|
|
|
@ -163,7 +163,11 @@ end
|
||||||
@param locale -- The locale the time should be formatted in
|
@param locale -- The locale the time should be formatted in
|
||||||
@return string -- The formatting string
|
@return string -- The formatting string
|
||||||
]=]
|
]=]
|
||||||
function DateTime.formatUniversalTime(self: DateTime, formatString: string?, locale: Locale?): string
|
function DateTime.formatUniversalTime(
|
||||||
|
self: DateTime,
|
||||||
|
formatString: string?,
|
||||||
|
locale: Locale?
|
||||||
|
): string
|
||||||
return nil :: any
|
return nil :: any
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,11 @@ end
|
||||||
@param level The compression level to use, clamped to the format's limits. The best compression level is used by default
|
@param level The compression level to use, clamped to the format's limits. The best compression level is used by default
|
||||||
@return The compressed string
|
@return The compressed string
|
||||||
]=]
|
]=]
|
||||||
function serde.compress(format: CompressDecompressFormat, s: buffer | string, level: number?): string
|
function serde.compress(
|
||||||
|
format: CompressDecompressFormat,
|
||||||
|
s: buffer | string,
|
||||||
|
level: number?
|
||||||
|
): string
|
||||||
return nil :: any
|
return nil :: any
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
export type Color = "reset" | "black" | "red" | "green" | "yellow" | "blue" | "purple" | "cyan" | "white"
|
export type Color =
|
||||||
|
"reset"
|
||||||
|
| "black"
|
||||||
|
| "red"
|
||||||
|
| "green"
|
||||||
|
| "yellow"
|
||||||
|
| "blue"
|
||||||
|
| "purple"
|
||||||
|
| "cyan"
|
||||||
|
| "white"
|
||||||
export type Style = "reset" | "bold" | "dim"
|
export type Style = "reset" | "bold" | "dim"
|
||||||
|
|
||||||
type PromptFn = (
|
type PromptFn = (
|
||||||
|
|
Loading…
Add table
Reference in a new issue