View Raw SPL
/*****************************************************************************
* *
* ISDTUNIT.SPL Copyright (C) 2025 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Returns 1 if input string is a date/time unit *
* *
* Revisions: 25 Mar 2025 RRR Creation *
* *
*****************************************************************************/
#if @HELP_ISDTUNIT
ISDTUNIT
Purpose: Returns 1 if the input string is a date or time unit.
Syntax: ISDTUNIT(str)
str - A string.
Returns: 1 if the input string is a date/time unit, else 0.
Example:
s1 = grand(100, 1);sethunits(s1, "daily");
s2 = grand(100, 1);sethunits(s2, "time");
s3 = grand(100, 1);sethunits(s3, "seconds");
isdtunit(gethunits(s1)) == 1
isdtunit(gethunits(s2)) == 1
isdtunit(gethunits(s3)) == 0
Both "daily" and "time" are considered date/time units, but
"seconds" is not considered a date/time unit.
Example:
isdtunit(3)
returns 0
Remarks:
See ISDT to determine if a series has date/time X units.
See SETDATE and SETTIME to set the series date and time.
If the input is not a series, ISDTUNIT returns 0.
See Also:
isdt
isrt
setdate
sethunits
settime
units
#endif
/* is string a date/time unit? */
isdtunit(s = "")
{
local status = 0;
if (isstring(s))
{
switch (tolower(s))
{
case "real time":
case "time":
case "daily":
case "date":
case "yearly":
case "monthly":
case "weekly":
case "quarterly":
case "minutely":
case "business days":
status = 1;
break;
default:
break;
}
}
return(status);
}