Built-in Units

DATETIME

The DateTime unit contains a group of features to make working with Dates and Times much easier. Modern Pascal's internal workings are based upon the Unix Timestamp, however, to keep compatible with other Pascal dialects we also support the TDateTime timestamp. To make life even easier, we try to treat both as the native timestamp. So no matter which way you are used to working with dates and times, this unit has your covered.

Globals

DecodeDate(DateTime:TDateTime;var Year,Month,Day:UInt16)
DecodeTime(DateTime:TDateTime;var Hour,Min,Sec,MSec:UInt16)
ReplaceDate(var DateTime:TDateTime;NewDate:TDateTime)
ReplaceTime(var DateTime:TDateTime;NewTime:TDateTime)

Functions

AdjustDays(T:TTimestamp;Days:Int32):TTimeStamp
AdjustHours(T:TTimestamp;Hours:Int32):TTimeStamp
AdjustMinutes(T:TTimestamp;Minutes:Int32):TTimeStamp
AdjustMonths(T:TTimestamp;Months:Int32):TTimeStamp
AdjustSeconds(T:TTimestamp;Seconds:Int32):TTimeStamp
AdjustYears(T:TTimestamp;Years:Int32):TTimeStamp
AppleToTimestamp(A:Int64):TTimestamp
CompareDatetime(D1,D2:TDatetime):Int32
CompareTimestamp(T1,T2:TTimestamp):Int32
Date:TDateTime
DateTimeToUTC(Dt:TDateTime):TDateTime
DayOfWeek(T:TTimestamp):Word
DayOfYear(T:TTimestamp):Word
DaysBetween(StartT,EndT:TTimestamp):Longint
DaysInThisMonth(Month,Year:Word):Word
DaysInThisYear(Year:Word):Word
DaySpan(StartT,EndT:TTimestamp):Longint
DecodeDateFully(DateTime:TDateTime;var Year,Month,Day,DOW:UInt16):Boolean
ElapsedTime(StartT,EndT:TTimestamp):String
ElapsedToStr(StartT,EndT:TTimestamp):String
EncodeDate(Year,Month,Day:UInt16):TDateTime
EncodeTime(Hour,Min,Sec,MSec:UInt16):TDateTime
FormatDateTime(Format:string;DateTime:TDateTime):string
FormatTimestamp(Format:string;T:TTimestamp):string
FromFileTime(FT:Longint):TTimestamp
GetAge(DOB:TTimestamp):Word
GetDays(T:TTimestamp):Word
GetDaysString(T:TTimestamp):String
GetHours(T:TTimestamp):Word
GetLocalTimeOffset:Longint
GetMinutes(T:TTimestamp):Word
GetMonths(T:TTimestamp):Word
GetSeconds(T:TTimestamp):Word
GetTickCount:UInt32
GetTickCount64:UInt64
GetYears(T:TTimestamp):Word
IsAM(DT:TDateTime):Boolean
IsAM(T:TTimestamp):Boolean
IsLeapYear(DT:TDateTime):Boolean
IsLeapYear(T:TTimestamp):Boolean
IsMidnight(T:TTimestamp):Boolean
IsNoon(T:TTimestamp):Boolean
IsPM(DT:TDateTime):Boolean
IsPM(T:TTimestamp):Boolean
IsWeekday(T:TTimestamp):Boolean
IsWeekend(T:TTimestamp):Boolean
JulianToTimeStamp(J:Double):TTimestamp
MonthsBetween(StartT,EndT:TTimestamp):Longint
Now:TDateTime
NowAsString(IncludeMS:Boolean=False):String
Sleep(MilliSeconds:UInt32)
StrToDate(s:string):TDateTime
StrToDateDef(s:string;Default:TDateTime):TDateTime
StrToDateTime(s:string):TDateTime
StrToDateTimeDef(s:string;Default:TDateTime):TDateTime
StrToTime(s:string):TDateTime
StrToTimeDef(s:string;Default:TDateTime):TDateTime
Time:TDateTime
TimestampAsBuild(T:TTimestamp):String
TimestampAsString(T:TTimestamp):String
TimestampToStr(T:TTimestamp):String
TimestampToUTC(T:TTimestamp):TTimestamp
ToApple(D:TDateTime):Int64
ToApple(T:TTimestamp):Int64
ToFileTime(T:TTimestamp):Longint
ToJulian(D:TDateTime):Double
ToJulian(T:TTimestamp):Double
UTCToDateTime(Dt:TDateTime):TDateTime
UTCToTimestamp(T:TTimestamp):TTimestamp
WeeksInThisYear(Year:Word):Word
WeekOfYear(T:TTimestamp):Word
WhenIsChristmasDay(Year:Word):TTimestamp
WhenIsChristmasEveDay(Year:Word):TTimestamp
WhenIsEaster(Year:Word):TTimestamp
WhenIsIndependenceDay(Year:Word):TTimestamp
WhenIsNewYearsDay(Year:Word):TTimestamp
WhenIsNewYearsEveDay(Year:Word):TTimestamp
WhenIsValentinesDay(Year:Word):TTimestamp
WithinPastDays(StartT,EndT:TTimestamp;Days:Word):Boolean
WithinPastMonths(StartT,EndT:TTimestamp;Months:Word):Boolean

Procedures

GetDate(T:TTimestamp;var Year,Month,Day:UInt16)
GetDateTime(T:TTimestamp;var Year,Month,Day,Hour,Min,Sec,MSec:UInt16)
GetTime(T:TTimestamp;var Hour,Min,Sec,MSec:UInt16)
SetDate(Var T:TTimestamp;Year,Month,Day:UInt16)
SetTime(Var T:TTimestamp;Hour,Min,Sec:UInt16;MSec:UInt64=0)