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)
|
||||
|
||||
assert(values.year == expectedDateTimeValues.year, `expected {values.year} == {expectedDateTimeValues.year}`)
|
||||
assert(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}`)
|
||||
assert(
|
||||
values.year == expectedDateTimeValues.year,
|
||||
`expected {values.year} == {expectedDateTimeValues.year}`
|
||||
)
|
||||
assert(
|
||||
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")
|
||||
|
||||
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)
|
||||
-- by colons, we should then get 3 substrings for each of date & time
|
||||
|
||||
local dateParts = string.split(string.sub(nowRfc, 1, dateTimeSplitIdx - 1), "-")
|
||||
local timeParts =
|
||||
string.split(string.sub(nowRfc, dateTimeSplitIdx + 1, ((timezoneSplitIdx or timezoneZeroedIdx) :: number) - 1), ":")
|
||||
local timeParts = string.split(
|
||||
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(#timeParts == 3, "Time partial of RFC 3339 should consist of 3 substrings, separated by ':'")
|
||||
|
@ -42,13 +51,22 @@ assert(
|
|||
|
||||
if timezoneZeroedIdx ~= nil then
|
||||
-- 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
|
||||
-- Timezone offset
|
||||
local timezoneParts = string.split(string.sub(nowRfc, timezoneSplitIdx + 1), ":")
|
||||
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(string.match(timezoneParts[2], "^%d%d$"), "Timezone partial should have 2 digits for minute")
|
||||
assert(
|
||||
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
|
||||
error("unreachable")
|
||||
end
|
||||
|
|
|
@ -4,9 +4,27 @@ local values = DateTime.fromRfc3339("2023-08-27T05:54:19Z"):toLocalTime()
|
|||
|
||||
local expectedDateTimeValues = os.date("*t", 1693115659)
|
||||
|
||||
assert(values.year == expectedDateTimeValues.year, `expected {values.year} == {expectedDateTimeValues.year}`)
|
||||
assert(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}`)
|
||||
assert(
|
||||
values.year == expectedDateTimeValues.year,
|
||||
`expected {values.year} == {expectedDateTimeValues.year}`
|
||||
)
|
||||
assert(
|
||||
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" })
|
||||
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
|
||||
@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
|
||||
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
|
||||
@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
|
||||
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"
|
||||
|
||||
type PromptFn = (
|
||||
|
|
Loading…
Add table
Reference in a new issue