إنتقل إلى المحتوى الرئيسي

DateTime():endOf()

يضبط كائن DateTime إلى نهاية وحدة زمنية محددة (مثال: نهاية اليوم، نهاية الشهر).

التوقيع

endOf(unit: string): DateTime

المعاملات

المعاملالنوعالوصف
unitstringوحدة الوقت المطلوب ضبط نهايتها. تشمل الوحدات المدعومة: year, month, week, day, hour, minute, second

القيمة المعادة

  • النوع: DateTime
  • نسخة DateTime الحالية، مما يسمح بتسلسل الدوال.

أمثلة

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"))