Skip to main content

Date & Time

Available constants

FamilyConstantsContract
Timestamp conversionDateDeltaInternal Delphi date-to-timestamp ordinal offset.
Nominal elapsed unitsFIVE_MINS_MILLI, ONE_HOUR_MILLI, EIGHT_HOUR_MILL, SecsPerDay, MSecPerDayInteger seconds or milliseconds; no timezone/calendar adjustment.
Weekday ordinalsMONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAYMonday=1 through Sunday=7.
Calendar/unit countsDaysPerWeek, WeeksPerFortnight, WeeksPerYear, FortnightPerYear, MonthsPerYear, YearsPerDecade, YearsPerCentury, YearsPerMillenniumExact unit ratios except the explicitly approximate year/week values.

Type and evaluation

All 21 entries are signed 32-bit LongInt compile-time constants. Their values are fixed when the script is compiled and do not read the clock, timezone, locale or Velox configuration. They can be used in constant expressions, but the surrounding expression's type still controls overflow and conversion.

The unit name matters. 300000 is milliseconds, not a TDateTime day fraction; 86400 is seconds, not milliseconds. Use explicit conversion functions or divide by the correct unit when constructing a TDateTime. Prefer IncMinute, IncHour, IncDay and other calendar-aware functions when the intended rule is a calendar change rather than nominal elapsed units.

Weekday numbering trap

The uppercase weekday constants are Monday-based (MONDAY=1 ... SUNDAY=7). They align with DateUtils DayOfTheWeek and ISO weekday numbering. They do not align with SysUtils DayOfWeek, which returns Sunday=1 through Saturday=7. Both ranges look valid, so mixing the APIs produces a silent semantic error rather than an out-of-range value.

Calendar and elapsed-time boundaries

  • A week and fortnight are exactly 7 and 14 nominal days.
  • A year is not exactly 52 weeks or 26 fortnights; those constants omit the remaining one or two days.
  • An ISO week-numbering year can contain week 53.
  • A month has variable length. MonthsPerYear=12 is a component count, not permission to use a fixed day duration.
  • A local civil day can be 23 or 25 elapsed hours across daylight-saving transitions. SecsPerDay and MSecPerDay are nominal 24-hour units.
  • Delphi TDateTime carries no timezone metadata and does not model leap seconds.

Numeric safety

MSecPerDay is already 86,400,000. Signed 32-bit multiplication by 25 overflows because the mathematical result is 2,160,000,000. Promote/accumulate in Int64 before multi-day millisecond arithmetic and still impose an application limit. Floating TDateTime calculations have different rounding and calendar concerns.

DateDelta is unrelated to these duration constants. It exists for Delphi's timestamp ordinal conversion and should be used only when reproducing that exact representation.

No runtime clock, calendar, timezone or image function was executed while documenting this branch.

External references

Created 2026-07-15