The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Better date/time functions (for QM < 2.3.2)
#1
For QM 2.3.1 and older. It is available in QM 2.3.2, with bug fixes.

Macro DateTime help
Code:
Copy      Help
;A variable of class DateTime represents a date and time.
;Class DateTime is similar to DATE.
;;;Advantages: more functions, better precision (supports milliseconds and microseconds).
;;;Disadvantages: there is no implicit conversion from/to str and some other types (need to use ToStr etc).

;Internally date/time is stored as long, in FILETIME format.
;It is number of ticks since January 1, 1601. A tick is 0.1 microseconds.

;A DateTime variable stores an absolute time. It doesn't store a time span (difference between two times).
;A time span can be stored in a variable of type long, in FILETIME format (number of 0.1 microsecond intervals). Can be negative.

;Also you can use operators with DateTime variables.
;Below are examples. Assume x and y are variables of DateTime type, and ts is variable of type long.
;;;x=y ;;set x = y
;;;ts=x-y ;;set ts = time span between x and y
;;;x=x+ts ;;add time span to x
;;;if(x<y) ... ;;if x is less than y

;Also there are several global (non member) functions to work with date/time. TimeSpanFromStr, DaysInMonth, etc.
;To show list of these functions, type "DateTime.".

;Most functions throw error if passed or calculated date/time values are out of range.
;Valid ranges of date/time parts are:
;;;year - 1601 to 9999. Actually may be stored dates up to about 30000, but some functions don't support it.
;;;month - 1 to 12.
;;;day - 1 to 28, 29, 30 or 31.
;;;hour - 0 to 23.
;;;minute - 0 to 59.
;;;second - 0 to 59.
;;;millisecond - 0 to 999.
;;;microsecond - 0 to 999.9.
;;;day of week - 0 (Sunday) to 6 (Saturday).
;;;day of year - 1 to 365 or 366.



;EXAMPLES

#compile "__DateTime"
DateTime x
x.FromComputerTime
out x.ToStr(8)

FUNCTIONS:
DateTime.FromComputerTime
DateTime.FromParts
DateTime.GetParts
DateTime.GetDatePart
DateTime.GetTimePart
DateTime.GetDayOfYear
DateTime.FromStr
DateTime.ToStr
DateTime.ToStrFormat
DateTime.FromDATE
DateTime.ToDATE
DateTime.FromFILETIME
DateTime.ToFILETIME
DateTime.FromSYSTEMTIME
DateTime.ToSYSTEMTIME
DateTime.AddParts
DateTime.AddStr
DateTime.AddMonths
DateTime.AddYears
DateTime.UtcFromLocal
DateTime.UtcToLocal
DateTime.SetComputerTime
TimeSpanFromParts
TimeSpanGetParts
TimeSpanGetPartsTotal
TimeSpanFromStr
TimeSpanToStr
DaysInMonth


Attached Files
.qml   DateTime.qml (Size: 17.55 KB / Downloads: 880)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)