next up previous contents FITSIO Home
Next: 5.8.3 General Utility Routines Up: 5.8 Utility Routines Previous: 5.8.1 File Checksum Routines   Contents

5.8.2 Date and Time Utility Routines

The following routines help to construct or parse the FITS date/time strings. Starting in the year 2000, the FITS DATE keyword values (and the values of other `DATE-' keywords) must have the form 'YYYY-MM-DD' (date only) or 'YYYY-MM-DDThh:mm:ss.ddd...' (date and time) where the number of decimal places in the seconds value is optional. These times are in UTC. The older 'dd/mm/yy' date format may not be used for dates after 01 January 2000. See Appendix B for the definition of the parameters used in these routines.

1
Get the current system date. C already provides standard library routines for getting the current date and time, but this routine is provided for compatibility with the Fortran FITSIO library. The returned year has 4 digits (1999, 2000, etc.)

  int fits_get_system_date/ffgsdt
      ( > int *day, int *month, int *year, int *status )

2
Get the current system date and time string ('YYYY-MM-DDThh:mm:ss'). The time will be in UTC/GMT if available, as indicated by a returned timeref value = 0. If the returned value of timeref = 1 then this indicates that it was not possible to convert the local time to UTC, and thus the local time was returned.

  int fits_get_system_time/ffgstm
      (> char *datestr, int  *timeref, int *status)

3
Construct a date string from the input date values. If the year is between 1900 and 1998, inclusive, then the returned date string will have the old FITS format ('dd/mm/yy'), otherwise the date string will have the new FITS format ('YYYY-MM-DD'). Use fits_time2str instead to always return a date string using the new FITS format.

  int fits_date2str/ffdt2s
      (int year, int month, int day, > char *datestr, int *status)

4
Construct a new-format date + time string ('YYYY-MM-DDThh:mm:ss.ddd...'). If the year, month, and day values all = 0 then only the time is encoded with format 'hh:mm:ss.ddd...'. The decimals parameter specifies how many decimal places of fractional seconds to include in the string. If `decimals' is negative, then only the date will be return ('YYYY-MM-DD').

  int fits_time2str/fftm2s
      (int year, int month, int day, int hour, int minute, double second,
      int decimals, > char *datestr, int *status)

5
Return the date as read from the input string, where the string may be in either the old ('dd/mm/yy') or new ('YYYY-MM-DDThh:mm:ss' or 'YYYY-MM-DD') FITS format. Null pointers may be supplied for any unwanted output date parameters.

  int fits_str2date/ffs2dt
      (char *datestr, > int *year, int *month, int *day, int *status)

6
Return the date and time as read from the input string, where the string may be in either the old or new FITS format. The returned hours, minutes, and seconds values will be set to zero if the input string does not include the time ('dd/mm/yy' or 'YYYY-MM-DD') . Similarly, the returned year, month, and date values will be set to zero if the date is not included in the input string ('hh:mm:ss.ddd...'). Null pointers may be supplied for any unwanted output date and time parameters.

  int fits_str2time/ffs2tm
      (char *datestr, > int *year, int *month, int *day, int *hour,
      int *minute, double *second, int *status)


next up previous contents FITSIO Home
Next: 5.8.3 General Utility Routines Up: 5.8 Utility Routines Previous: 5.8.1 File Checksum Routines   Contents