>  Docs Center  >  Libraries  >  Mankoff  >  KDM_DT__DEFINE
Libraries

KDM_DT__DEFINE

KDM_DT__DEFINE

Class Name


KDM_DT

Purpose


  A datetime object stores a date and/or time

Category


  Date, Time, Object

Superclasses


  Inherits the KDM object

Subclasses


  None

Creation


  Result = OBJ_NEW( 'kdm_dt' )

Methods


  TimeStamp, setProperty, Init, Cleanup

Restrictions


  * Does not pay attention to leap year
  * Accepts conflicting keywords and defaults (dt->setProperty, month=2, doy=2)
  * Does not understand timezones. Defaults to UTC for /NOW keyword
    and TimeStamp() function
  * ...

Modification History


  Written by: Ken Mankoff, 2009.
2009-09-22: Added documentation
2009-09-22: Added /NOW
      2009-10-03: DOY is set when /NOW is used
  =============================================================
  METHODNAME:
  KDM_DT::TimeStamp

Purpose


  Return a timestamp based on the current date and time of this
  object. Format is: YYYY-MM-DDThh:mm:ssZ

Calling Sequence


  Result = KDM_DT -> TimeStamp()

Outputs


  A string based on the current date and time of this object.
  Format is: YYYY-MM-DDThh:mm:ssZ

Example


  To get the current date and time:
  dt = obj_new( 'kdm_dt', /now )
  print, dt->TimeStamp()
  =============================================================
  METHODNAME:
  KDM_DT::SetProperty

Purpose


  Set the properties of this date/time object

Calling Sequence


  Obj -> SetProperty

Keyword Parameters


YEAR, MONTH, STRMONTH, DAY, DOY, HOUR, MINUTE, SECOND
  STRMONTH: The month in string format ("Sep", or "September")
  DAY: The day of the month.
  DOY: The day of year. Can be fractional

Procedure


  If a keyword overwrites an existing value then all values are set
  to null and the object is essentially re-initialized. If an
  existing does not already exist then the object is modified (ex:
  Call once and set year to X, then call a second time and set hour
  to Y)
  If any other properties can be determined from an input they are
  set. For example, if DOY is set to a fraction, month, day, hour,
  minute, and second will all be filled in.
 

Example


  To set the year of a KDM_DT object:
  IDL> dt = obj_new( 'kdm_dt' )
  IDL> dt->setProperty, year=2012
  IDL> print, dt->TimeStamp()
  2012
  To set the day-of-year (fractional)
  IDL> dt->setProperty, doy=42.24
  IDL> print, dt->TimeStamp()
  2012-02-11T05:45:36Z
  =============================================================
  METHODNAME:
  KDM_DT::Init

Purpose


  Create and initialize a KDM_DT object

Calling Sequence


  dt = OBJ_NEW( 'kdm_dt' )

Keyword Parameters


NOW: Initialize with the current date and time
  See SetProperty for other optional inputs

Outputs


  A KDM_DT object is returned. It is initialized with default values
  passed in.

Procedure


  Create the object. Pass _EXTRA to SetProperty.

Example


  dt = OBJ_NEW( 'kdm_dt' )
  dt = OBJ_NEW( 'kdm_dt', /NOW )
  dt = OBJ_NEW( 'kdm_dt', YEAR=2012, monthStr='Feb', day=10, hour=13.3 )



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us