home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / !DeskLib / h / Time < prev    next >
Encoding:
Text File  |  1994-05-29  |  3.9 KB  |  105 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Desklib:Time.h
  12.     Author:  Copyright © 1992, 1993, 1994 Jason Williams, Jason Howat
  13.     Version: 1.02 (22 May 1994)
  14.     Purpose: time handling
  15. */
  16.  
  17.  
  18. #ifndef __dl_time_h
  19. #define __dl_time_h
  20.  
  21. #ifndef __dl_core_h
  22. #include "DeskLib:Core.h"
  23. #endif
  24.  
  25.  
  26.   /*  Time_Monotonic
  27.    *  Veneer for the OS_ReadMonotonicTime SWI
  28.    *  Returns an integer representing the time since the computer was switched
  29.    *  on, in centiseconds.
  30.    *  Used with Wimp_PollIdle to poll every now and then, as in:
  31.    *    time = Time_Monotonic();
  32.    *    Wimp_PollIdle(mask, block, time + 100);  // Pollidle for 1 sec (100cs)
  33.    *
  34.    *  Can also be used to time things, i.e.
  35.    *    time = Time_Monotonic();
  36.    *    while (Time_Monotonic < time+100) |* wait *| ;    // Wait for 1 second
  37.    */
  38. extern int Time_Monotonic(void);
  39.  
  40.  
  41.  
  42. /* Time_ConvertDateAndTime -------------------------------------------------
  43.  * Veneer for the OS_ConvertDateAndTime SWI.
  44.  * Uses the format string to convert the given time to text.
  45.  * Format codes:                             Field size:
  46.  *   CS      Centiseconds                        2
  47.  *   SE      Seconds                             2
  48.  *   MI      Minutes                             2
  49.  *   12      Hours (12hr format)                 2
  50.  *   24      Hours (24hr format)                 2
  51.  *   AM      'am' or 'pm'                        2
  52.  *   PM      ditto                               2
  53.  *   WE      Weekday                           varies
  54.  *   W3      Weekday (3 chars)                   3
  55.  *   WN      Weekday as number                   1
  56.  *   DY      Day of the month                    2
  57.  *   ST      'st', 'nd', 'rd' or 'th'            2
  58.  *   MO      Month name                        varies
  59.  *   M3      Month name (3 chars)                3
  60.  *   MN      Month as number                     2
  61.  *   CE      Century                             2
  62.  *   YR      Year within century                 2
  63.  *   WK      Week number (Mon-Sun)               2
  64.  *   DN      Day of year                         3
  65.  *   0       Insert an ASCII 0 byte              1
  66.  *   %       Insert a '%'                        1
  67.  */
  68. extern os_error *Time_ConvertDateAndTime(char *fivebyteblock, char *buffer,
  69.                                          int bufflen, char *format);
  70.  
  71.   /*  Six time formats for ConvertDateAndTime are pre-defined for you:
  72.    *  
  73.    *  1. Time_CTIME is equal to ctime() found in ANSI C <time.h> without
  74.    *     the automatic \n inserted
  75.    *  
  76.    *  2. Time_STANDARD is the default setting found on most Arcs and not
  77.    *     the system variable <Sys$DateFormat>
  78.    *  
  79.    *  3. Time_FANCYDATE is Sunday, 16th of January, 1994.
  80.    *  
  81.    *  4. Time_SHORTTIME is 11:30pm
  82.    *  
  83.    *  5. Time_LONGTIME is 11:30:12pm
  84.    *  
  85.    *  6. Time_EUROTIME is 23:30:12
  86.    */
  87.    
  88. #define Time_CTIME     "%W3 %M3 %DY %z24:%MI:%SE %CE%YR"
  89. #define Time_STANDARD  "%24:%mi:%se %dy-%m3-%ce%yr"
  90. #define Time_FANCYDATE "%WE, %zDY%ST of %MO, %CE%YR"
  91. #define Time_SHORTTIME "%z12:%MI%pm"
  92. #define Time_LONGTIME  "%z12:%MI:%SE%pm"
  93. #define Time_EUROTIME  "%z24:%MI:%SE"
  94.  
  95.  
  96. /* Time_ConvertStandardDateAndTime -----------------------------------------
  97.  * Veneer for the OS_ConvertStandardDateAndTime SWI.
  98.  * Converts the given time into a string using the format string stored in
  99.  * Sys$DateFormat.
  100.  */
  101. extern os_error *Time_ConvertStandardDateAndTime(char *fivebyteblock,
  102.                                                  char *buffer, int bufflen);
  103.  
  104. #endif
  105.