mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
feat(types): datetime -> DateTime & fix typing
This commit is contained in:
parent
eb642473e3
commit
2ca9615441
10 changed files with 12 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
-- UTC Timezone
|
-- UTC Timezone
|
||||||
assert(
|
assert(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
DateTime.fromIsoDate("2023-08-26T16:56:28Z") ~= nil,
|
DateTime.fromIsoDate("2023-08-26T16:56:28Z") ~= nil,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
assert(
|
assert(
|
||||||
DateTime.fromLocalTime()["unixTimestamp"] == os.time(),
|
DateTime.fromLocalTime()["unixTimestamp"] == os.time(),
|
||||||
"expected DateTime.fromLocalTime() with no args to return DateTime at current moment"
|
"expected DateTime.fromLocalTime() with no args to return DateTime at current moment"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
DateTime.fromUniversalTime()["unixTimestamp"] == os.time(),
|
DateTime.fromUniversalTime()["unixTimestamp"] == os.time(),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
-- Bug in rust side implementation for fromUnixTimestamp, calculation for conversion there is wonky,
|
-- Bug in rust side implementation for fromUnixTimestamp, calculation for conversion there is wonky,
|
||||||
-- a difference of few millis causes differences as whole seconds for some reason
|
-- a difference of few millis causes differences as whole seconds for some reason
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
local TYPE = "DateTime"
|
local TYPE = "DateTime"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
string.match(
|
string.match(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
local dateTime = (DateTime.fromIsoDate("2023-08-27T05:54:19Z") :: DateTime.DateTime):toLocalTime()
|
local dateTime = (DateTime.fromIsoDate("2023-08-27T05:54:19Z") :: DateTime.DateTime):toLocalTime()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
local dateTime = (DateTime.fromIsoDate("2023-08-27T05:54:19Z") :: DateTime.DateTime):toLocalTime()
|
local dateTime = (DateTime.fromIsoDate("2023-08-27T05:54:19Z") :: DateTime.DateTime):toLocalTime()
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,8 @@ export type DateTime = {
|
||||||
unixTimestampMillis: number,
|
unixTimestampMillis: number,
|
||||||
|
|
||||||
toIsoDate: (self: DateTime) -> string,
|
toIsoDate: (self: DateTime) -> string,
|
||||||
toLocalTime: (self: DateTime) -> DateTimeValues,
|
toLocalTime: (self: DateTime) -> DateTimeValues & { month: number },
|
||||||
toUniversalTime: (self: DateTime) -> DateTimeValues,
|
toUniversalTime: (self: DateTime) -> DateTimeValues & { month: number },
|
||||||
|
|
||||||
formatTime: (
|
formatTime: (
|
||||||
self: DateTime,
|
self: DateTime,
|
||||||
|
@ -66,7 +66,7 @@ export type DateTime = {
|
||||||
### Example usage
|
### Example usage
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
-- Returns the current moment in time as a ISO 8601 string
|
-- Returns the current moment in time as a ISO 8601 string
|
||||||
DateTime.now():toIsoDate()
|
DateTime.now():toIsoDate()
|
Loading…
Add table
Reference in a new issue