DateTime():endOf()
Définit l'objet DateTime à la fin d'une unité de temps spécifiée (par ex., fin du jour, fin du mois).
Signature
endOf(unit: string): DateTime
Paramètres
| Paramètre | Type | Description |
|---|---|---|
unit | String | L'unité de temps dont il faut définir la fin. Les unités prises en charge incluent :year, month, week, day, hour, minute, second |
Renvoie
- Type :
DateTime - L'instance
DateTimeactuelle, permettant le chaînage des méthodes.
Exemples
local now = DateTime()
-- Set to the end of the current day
now:endOf("day")
toast("End of day: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the end of the current month
now = DateTime() -- Reset
now:endOf("month")
toast("End of month: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the end of the current year
now = DateTime() -- Reset
now:endOf("year")
toast("End of year: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))