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

Sunlit Design > The Sun API > Documentation > sdSDYx Function


Index


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

Contact Developer

Downloads

sdSDYx Function

Description

Returns a Solar Day of Year (SDY) time value.  

sdSDYx converts a Month, Day and 24 hour clock time for a given Timezone into a Solar Day of Year value.  

The sdxAlt, sdxAzi, sdxDecl, sdxEOT, sdxFindAnnFeatx, sdxH, sdxGetv, sdxTime2Text, and sdxTimeUnpackx functions all use SDY time values.

Syntax

sdSDYx(month, day, hour, minute, second, timezone)

month   

Month number from 1 to 12.  January  = 1, ..., December = 12.

day   

any positive or negative number of Days.

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

timezone   

a timezone value between -13 and 12

Return Values

sdSDYx returns an XML String. Assuming "nnn" stands for the numeric SDY value between 0 and 365 that is returned and "tz" the numeric value of the timezone, the SDY time value will have the following format:
  

"nnn <SDY> nnn </SDY><TimeZone> tz </TimeZone>"

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",sdSDYx(...)) will return a non-zero value.

Remarks

This function calculates it's return value by finding the SDY of the beginning of the month then adding the sum of the days, hours, timezone, minutes, and seconds. If the result is less than 1 or greater than 365.99999... then the number is reduced to the range 1-365.99999...

More formally this can be expressed in the following Basic-like language snippet:
    days = daynumberofstartof(month)
    days = days + day + (hour+ timezone+ minute/60+ second/3600)/24
    return reduce1-365(days)

February is counted has having 28 days.  

February 29th - If you wish to find solar parameters for a specific February 29th, then please use the sdMJDx function.

The string SDY 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 SDY value corresponding to Midnight UT Jan 5:
    sdxGetv("",sdSDYx(1,5,0,0,0,0))equals 5.0

This avoids the duplication inherent in it's equivalent:
    sdxGetv("SDY",sdSDYx(1,5,0,0,0,0))equals 5.0

In a SDY time value with an appended Time Zone - for example: "23.3<SDY> 23.3</SDY><TimeZone> 5 </TimeZone>" The TimeZone value is informational only and doesn't affect the SDY value.

To find the day number of the first day of month m, use 
    sdSDYx(m,1,0,0,0,0) 
and convert the resulting XML string to a number using 
    sdxGetv("",sdSDYx(m,1,0,0,0,0)) 

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

Example

Find the SDY value corresponding to February 23rd, 2:12 pm Eastern Standard Time (USA) (+5 gives UT):
    sdSDYx(2,23,2,12,0,5)
       
equals "54.3<SDY> 54.3</SDY><TimeZone> 5 </TimeZone>"

Find the numeric value of the SDY value corresponding to November 17th, 7pm in Amsterdam (not Daylight saving):

    sdxGetv("",sdSDYx(11,17,19,0,0,-1)) equals 321.75 

And also using an explicit reference to the time value:

    sdxGetv("SDY",sdSDYx(11,17,19,0,0,-1)) equals 321.75

And also retrieve the TimeZone from the time value:

   sdxGetv("TimeZone",sdSDYx(11,17,19,0,0,-1)) equals -1

Find the SDY value corresponding to midday UT, February 29th:
    sdSDYx(2,29,12,0,0,0) equals "60.5 <SDY> 60.5</SDY><TimeZone> 0</TimeZone>"  which is the value of 29 days after the beginning of February i.e. March 1st!

Find the SDY value corresponding to midday UT, March 1st:
    sdSDYx(3,1,12,0,0,0) equals "60.5 <SDY> 60.5</SDY><TimeZone> 0</TimeZone>"

Print a list of Solar Declinations (in degrees) for midday in Almaty Kazakhstan (-6 gives UT) for everyday of the year:
    for i = 1 to 365
        print i,sdxDecl(sdSDYx(1,i,12,0,0,-6))
    next i