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

Sunlit Design > The Sun API > Documentation > sdMJDx Function


Index


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

Contact Developer

Downloads

sdMJDx Function

Description

Returns a Modified Julian Day (MJD) time value.  

sdSDYx converts a Year, Month, Day and 24 hour clock time for a given Timezone into a Modified Julian Day (MJD) value.  

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

Syntax

sdMJDx(year, month, day, hour, minute, second, timezone)

year   

Year number from -4712 to 9999. See Years A.D and B.C.

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

sdMJDx returns an XML String. Assuming "nnn" stands for the numeric MJD value that is returned and "tz" the numeric value of the timezone, the MJD time value will have the following format:
  

"nnn <MJD> nnn </MJD><TimeZone> tz </TimeZone>"

sdMJDx will return an MJD between -2400000.5 (Noon 1st Jan -4711) and 2973484.9999... (31st Dec 9999)

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 MJD of the beginning of the month for the given year then adding the sum of the days, hours, timezone, minutes, and seconds.

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

The string MJD 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 MJD value corresponding to Midnight UT Jan 1, 2000:
    sdxGetv("",sdMJDx(2000,1,1,0,0,0,0))equals 51544.0

This avoids the duplication inherent in it's equivalent:
    sdxGetv("MJD",sdMJDx(2000,1,1,0,0,0,0))equals 51544.0

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

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

Example

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

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

    sdxGetv("",sdMJDx(2004,11,17,19,0,0,-1)) equals 53326.75

And also using an explicit reference to the time value:

    sdxGetv("MJD",sdMJDx(11,17,19,0,0,-1)) equals 53326.75

And also retrieve the TimeZone from the time value:

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

Find the MJD value corresponding to midday UT, February 29th 2004:
    sdMJDx(2004,2,29,12,0,0,0)  
        equals "53064.5<MJD> 53064.5</MJD><TimeZone> 0</TimeZone>

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