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
Date:TDateTime
DayOfWeek(T:TTimestamp):Word
DayOfYear(T:TTimestamp):Word
DaysBetween(StartT,EndT:TTimestamp):Longint
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
GetMinutes(T:TTimestamp):Word
GetMonths(T:TTimestamp):Word
GetSeconds(T:TTimestamp):Word
GetTickCount:UInt32
GetTickCount64:UInt64
GetYears(T:TTimestamp):Word
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
ToFileTime(T:TTimestamp):Longint
WeekOfYear(T:TTimestamp):Word
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)