1 /* @include ajtime ************************************************************ 2 ** 3 ** AJAX time functions 4 ** 5 ** @author Copyright (C) 1998 Ian Longden 6 ** @author Copyright (C) 2003 Jon Ison 7 ** @version $Revision: 1.27 $ 8 ** @modified 2004-2011 Peter Rice 9 ** @modified $Date: 2011/10/18 14:23:41 $ by $Author: rice $ 10 ** @@ 11 ** 12 ** This library is free software; you can redistribute it and/or 13 ** modify it under the terms of the GNU Lesser General Public 14 ** License as published by the Free Software Foundation; either 15 ** version 2.1 of the License, or (at your option) any later version. 16 ** 17 ** This library is distributed in the hope that it will be useful, 18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 ** Lesser General Public License for more details. 21 ** 22 ** You should have received a copy of the GNU Lesser General Public 23 ** License along with this library; if not, write to the Free Software 24 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 ** MA 02110-1301, USA. 26 ** 27 ******************************************************************************/ 28 29 #ifndef AJTIME_H 30 #define AJTIME_H 31 32 /* ========================================================================= */ 33 /* ============================= include files ============================= */ 34 /* ========================================================================= */ 35 36 #include "ajdefine.h" 37 #include "ajstr.h" 38 39 #include <time.h> 40 41 AJ_BEGIN_DECLS 42 43 44 45 46 /* ========================================================================= */ 47 /* =============================== constants =============================== */ 48 /* ========================================================================= */ 49 50 51 52 53 /* ========================================================================= */ 54 /* ============================== public data ============================== */ 55 /* ========================================================================= */ 56 57 58 59 60 /* @data AjPTime ************************************************************** 61 ** 62 ** AJAX time and data data structure. The same structure is used for both. 63 ** 64 ** @alias AjSTime 65 ** @alias AjOTime 66 ** @alias AjPDate 67 ** 68 ** @attr time [struct tm] Time in C standard structure 69 ** @attr format [const char*] Format string if specified 70 ** @attr uppercase [AjBool] Convert to upper case on output 71 ** @attr Padding [char[4]] Padding to alignment boundary 72 ** @@ 73 ******************************************************************************/ 74 75 typedef struct AjSTime 76 { 77 struct tm time; 78 const char *format; 79 AjBool uppercase; 80 char Padding[4]; 81 } AjOTime, AjODate; 82 83 #define AjPTime AjOTime* 84 #define AjPDate AjODate* 85 86 87 88 89 /* ========================================================================= */ 90 /* =========================== public functions ============================ */ 91 /* ========================================================================= */ 92 93 94 95 96 /* 97 ** Prototype definitions 98 */ 99 100 double ajTimeDiff(const AjPTime thys, const AjPTime newtime); 101 void ajTimeExit(void); 102 AjBool ajTimeSetLocal(AjPTime thys, const time_t timer); 103 104 AjPTime ajTimeNewDayFmt(const char *timefmt, 105 ajint mday, ajint mon, ajint year); 106 AjPTime ajTimeNewToday(void); 107 AjPTime ajTimeNewTodayFmt(const char* timefmt); 108 109 void ajTimeDel(AjPTime *thys); 110 111 const AjPTime ajTimeRefToday(void); 112 const AjPTime ajTimeRefTodayFmt(const char* timefmt); 113 114 void ajTimeTrace(const AjPTime thys); 115 AjBool ajTimeSetC(AjPTime thys, const char* timestr); 116 AjBool ajTimeSetS(AjPTime thys, const AjPStr timestr); 117 AjPTime ajTimeNew(void); 118 AjPTime ajTimeNewTime(const AjPTime thys); 119 time_t ajTimeGetTimetype(const AjPTime thys); 120 void ajTimeReset(void); 121 122 ajlong ajClockNow(void); 123 void ajClockReset(void); 124 double ajClockDiff(ajlong starttime, ajlong nowtime); 125 double ajClockSeconds(void); 126 127 /* 128 ** End of prototype definitions 129 */ 130 131 132 133 134 #ifdef AJ_COMPILE_DEPRECATED_BOOK 135 #endif /* AJ_COMPILE_DEPRECATED_BOOK */ 136 137 #ifdef AJ_COMPILE_DEPRECATED 138 139 __deprecated AjPTime ajTimeToday(void); 140 __deprecated AjPTime ajTimeTodayF(const char* timefmt); 141 __deprecated const AjPTime ajTimeTodayRef(void); 142 __deprecated const AjPTime ajTimeTodayRefF(const char* timefmt); 143 __deprecated AjPTime ajTimeSet(const char *timefmt, 144 ajint mday, ajint mon, ajint year); 145 __deprecated time_t ajTimeMake(const AjPTime thys); 146 __deprecated AjBool ajTimeLocal(const time_t timer, AjPTime thys); 147 148 #endif /* AJ_COMPILE_DEPRECATED */ 149 150 151 152 153 AJ_END_DECLS 154 155 #endif /* !AJTIME_H */ 156