How to work with DateTime

1. Create a  DateTime object

this_datetime = datetime( '2002/05/31 0:56:43' )
Creates a datetime object and stores the values given. The value can be any anytim format.

Remember to destroy the DateTime object after usage with
obj_destroy, this_datetime

Please trash your objects after usage -- so you will help keeping a clean environment.

2. Set other values to the object

this_datetime->set, value
will set any (anytim) value to the object

3. Get the value from the object

value = this_datetime->get( /xxx )
where xxx stands for any anytim format

4. Print the datetime

this_datetime->print

5. Operations on the datetime object

this_datetime->round, /month
rounds itself to the month

new_datetime = this_datetime->round( /month, /obj_new )
creates a new datetime object rounded to the month

new_datetime = this_datetime->round( /month, /anytim )
returns an anytim rounded to the month

clone_datetime = this_datetime->clone()
returns an objet copy of itself

file_index = this_datetime->time2file()
returns a string with date/time formatting

this_date->increment, /month
increments the date by a full month (i.e. 2002/02/28 -> 2002/03/28)

6. Comparison operators

if this_datetime->lessthan( other_datetime ) then print, 'this date less than other date'

if this_datetime->lessthan( '2002/03/30' ) then print, 'this date less than 2002/03/30'

7. Why use the datetime object?

This datetime object represents a "new" class oj objects that does not really appear in the curent RHESSI sofware. The goal is to encapsulate all operations associated with a datatime in an object. It is not a new idea; it is in fact just an abstract data type. The object granularity here is the inverse as in the RHESSI sofware. In fact the RHESSI objects are functional entities. These ones, in contrast, are "beans", that provides specific functionality for  relatively simple data types. So while in the RHESSI sofware we deal with large objects that have few methods (basically get, set, getdata), here we deal with small objects that have lots of procedures.



André Csillaghy csillag@ssl.berkeley.edu
October 2003