File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ function DateTime:new(input)
28
28
self .__index = self
29
29
30
30
datetime .date = date (input )
31
+ datetime .timestamp = datetime .date :spanseconds ()
31
32
32
33
return datetime
33
34
end
38
39
39
40
--- Add time to date
40
41
--- @param unit " years" | " months" | " days" | " hours" | " minutes" | " seconds"
41
- --- @param value
42
+ --- @param value number
42
43
function DateTime :add (unit , value )
43
44
44
45
if unit == " years" then
@@ -82,7 +83,7 @@ function DateTime:nice(opts)
82
83
local default_format = opts and opts .format or " %A, %B %d"
83
84
local show_close_dates = opts and opts .show_close_dates or false
84
85
local now = DateTime :new (nil )
85
- local days = math.ceil (date .diff (self .date , now .date ):spandays ())
86
+ local days = math.floor (date .diff (self .date , now .date ):spandays ())
86
87
87
88
local str = " In " .. days .. " days"
88
89
186
187
--- Get relative hours
187
188
--- @return number
188
189
function DateTime :relative_hours ()
190
+ return self :diff_hours ()
191
+ end
192
+
193
+ function DateTime :diff_hours ()
189
194
local diff = self :diff_object ()
190
195
return diff :spanhours ()
191
196
end
You can’t perform that action at this time.
0 commit comments