View Raw SPL
/****************************************************************************
*                                                                           *
*   GETXDATE.SPL Copyright 2010 (C) DSP Development Corporation             *
*                                                                           *
*   Author:      Randy Race                                                 *
*                                                                           *
*   Synopsis:    Returns X coordinates as date values                       *
*                                                                           *
*   Revisions:   12 Apr 2010     RRR     Creation                           *
*                                                                           *
****************************************************************************/

#include 

#if @HELP_GETXDATE

    GETXDATE

    Purpose: Returns the x-axis coordinate range of a Window as date values.

    Syntax:  GETXDATE(window)

             (xldate, xrdate) = GETXDATE(window)

              window - Optional. Window reference. Defaults to the current
                       Window.


    Returns: A string. The left hand date value of the displayed data.

             (xldate, xrdate) = GETXDATE(window) returns both the left
             and right date strings.

    Example:
             W1:gnorm(1000, 1);setdate("1-1-2010");sethunits("daily");
             setxdate(W1,"7-20-10", "8-24-2011");
             (xldate, xrdate) = getxdate(W1);

             xldate == "7/20/10"
             xrdate == "8/24/11"

             creates a 1000 point series with horizontal time units of
             Daily. The starting date is 1-1-2010. The X axis is set
             to display data between 7-20-2010 and 8-24-2011. The left
             and right date strings of the displayed data are returned.

    Remarks:
             The horizontal units of the series must be a date unit
             such as Daily, Monthly or Yearly.

             See SETXDATE to set the x-axis coordinates in date values.

             See GETXL and GETXR to return the x-axis coordinates in
             terms of the delta-x between values.

    See Also:
             GETXL
             GETXR
             GETXTIME
             SETX 
             SETHUNITS
             SETXDATE
             SETXTIME
#endif


/* get x axis values as date strings */
getxdate(win)
{
        local xl, xr, date_offset;

        if (argc < 1)
        {
                win = refwin(w0);
        }

        date_offset = julstr(getdate(win));

        xl = getxl(win);
        xr = getxr(win);

        xl = strjul(xl + date_offset);
        xr = strjul(xr + date_offset);

        if (outargc > 1)
        {
                return(xl, xr);
        }
        else
        {
                return(xl);
        }
}