DateTime():startOf()
يضبط كائن DateTime إلى بداية وحدة زمنية محددة (مثال: بداية اليوم، بداية الشهر).
التوقيع
startOf(unit: string): DateTime
المعاملات
| المعامل | النوع | الوصف |
|---|---|---|
unit | string | وحدة الوقت المطلوب ضبط بدايتها. تشمل الوحدات المدعومة: year, month, week, day, hour, minute, second |
القيمة المعادة
- النوع:
DateTime - نسخة
DateTimeالحالية، مما يسمح بتسلسل الدوال.
أمثلة
local now = DateTime()
-- Set to the start of the current day
now:startOf("day")
toast("Start of day: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the start of the current month
now = DateTime() -- Reset
now:startOf("month")
toast("Start of month: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))
-- Set to the start of the current year
now = DateTime() -- Reset
now:startOf("year")
toast("Start of year: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS"))