TapHome

Date and time

TapHome script date and time functions — DATETIME, NOW, TIMESPAN, LOCALTIMEZONE, and DATETIMEADD for creating and manipulating date/time values.

DATETIME

Creates a DateTime object. DateTime.Ticks property is number of milliseconds from 1.1.0001 00:00:00.000. DateTime has properties: TICKS, YEAR, MONTH, DAY, DAYOFWEEK, DAYOFYEAR, HOUR, MINUTE, SECOND, MILLISECOND, KIND, UTCDATETIME, LOCALDATETIME, UNIXTIME

DATETIME( ticks, DateTimeKind )
DATETIME( string, format )
DATETIME( string, DateTimeKind )
DATETIME( year, month, day, hour, minute, second, millisecond, DateTimeKind  )

Examples:

VAR date:= DATETIME(2014, 12, 8, 23, 54, 12, 456);
VAR date:= DATETIME(2014, 12, 8, 23, 54, 12, 456, DateTimeKind.Local);
VAR date:= DATETIME(2014, 12, 8, 23, 54, 12, 456, DateTimeKind.Utc);
VAR date:= DATETIME("13:36");
VAR date:= DATETIME("2022-08-03T07:39:03.688133+05:00");
VAR date:= DATETIME("03.01 2008 10:00"); 
VAR date:= DATETIME("mar.01 2008 10:00");
VAR date:= DATETIME("03.01 2008 10:00", "dd.MM yyyy hh:mm");
VAR date:= DATETIME(518832000);
VAR date:= DATETIME(518832000, DateTimeKind.Utc);
VAR date := NOW(); date.YEAR := 1999;
DATETIME date; date.UNIXTIME := 123456;

NOW

Returns DateTime object that is set to current date and time in local timezone.

NOW()

Examples:

VAR now := NOW();

TIMESPAN

The TIMESPAN function creates a variable that represents a duration of time, specified in terms of days, hours, minutes, seconds, and milliseconds. The TIMESPAN has properties to directly access each component of the timespan: DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS. The TIMESPAN has properties to access the total value of time in specific units (including fractional values): TOTALDAYS, TOTALHOURS, TOTALMINUTES, TOTALSECONDS, TOTALMILLISECONDS

TIMESPAN( days, hours, minutes, seconds, milliseconds )

Examples:

VAR t := TimeSpan(1, 2, 3, 4, 0);
	t.TOTALSECONDS			

Result ... 93784

LOCALTIMEZONE

Returns local timezone as number of milliseconds from UTC time.

LOCALTIMEZONE()

Examples:

VAR timezoneDiff := LOCALTIMEZONE();

DATETIMEADD

Adds specified number of years, months, days, hours, minutes, seconds, milliseconds to existing DateTime and returns a new DateTime.

DATETIMEADD(datetime, years, months, days, hours, minutes, seconds, milliseconds)

Examples:

VAR dt := NOW(); VAR yearBefore := DATETIMEADD(dt, -1);