This site Web
Home Page | The Sun API | Gallery | InfoSearch | News | Links | Contact Us

Sunlit Design > The Sun API > Documentation > sdCTDx Function


Index


- Introduction
+ Using the Functions
+ User Guide
+ Function Reference
+ Constants

Contact Developer

Downloads

sdCTDx Function

Description

Returns a Clock Time Day (CTD) time value.  

sdCTDx converts a 24 hour clock time into a portion of a day for use by the sdxH function.

Syntax

sdCTDx(hour, minute, second)

hour   

any positive or negative number of Hours.  0 is midnight, 12 is midday and 18 is 6 pm.  

minute   

any positive or negative number of Minutes

second   

any positive or negative number of Seconds

Return Values

sdCTDx returns an XML String. Assuming "nnn" stands for the numeric CTD value between 0 and 1 that is returned, the CTD time value will have the following format:

"nnn <CTD> nnn </CTD>"

Errors

If the function detects an error in any of it's input parameters then it returns: "-99999999<Error>-99999999</Error>"

If the function returns an error value, then:
    sdxGetv("Error",sdCTDx(...)) will return a non-zero value.

Remarks

This function calculates it's return value by converting the sum of the hours, minutes and seconds to a number of days then returning the decimal (part of day) portion.

More formally this can be expressed in the following Basic language snippet:
    days = (hour+minute/60+second/3600)/24
    return days-int(days)

The string CTD time value may be converted to a simple numeric value using the sdxGetv function.

The XML string that this function returns has the numerical value of the result at the beginning of the string followed by the result in proper XML format.  This value is the default numeric value of the string.  It may be returned using the sdxGetv("",) function. For example:

Find the numeric value of the CTD value corresponding to 7:12pm:
    sdxGetv("",sdCTDx(19,12,0))equals .8     

This avoids the duplication inherent in it's equivalent:
    sdxGetv("CTD",sdCTDx(19,12,0))equals .8      

The useful resolution of this time measure is approximately 1/10 of a millisecond.

Example

Find the CTD value corresponding to 7:12pm:
    sdCTDx(19,12,0)equals ".8<CTD> .8</CTD>"

Find the numeric value of the CTD value corresponding to 6pm:

    sdxGetv("",sdCTDx(18,0,0)) equals .75 

And also using an explicit reference to the time value:

    sdxGetv("CTD",sdCTDx(18,0,0)) equals .75

Find the CTD value of 10,800 seconds past midnight:
    sdCTDx(0,0,10800) equals ".125<CTD> .125</CTD>"

Find the CTD value of 10,800 seconds before midnight:
    sdCTDx(0,0,-10800) equals ".875<CTD> .875</CTD>"