2 * \file gammu-datetime.h
5 * Date and time manipulations.
7 #ifndef __gammu_datetime_h
8 #define __gammu_datetime_h
11 * \defgroup DateTime Date and time
12 * Date and time handling.
16 #include <gammu-error.h>
17 #include <gammu-statemachine.h>
20 * Structure used for saving date and time
26 * The difference between local time and GMT in seconds
48 * January = 1, February = 2, etc.
52 * Complete year number. Not 03, but 2003
58 * Structure used for saving relative date and time
64 * The difference of timezones in seconds
96 * Returns string for current day of week.
102 * \return Pointer to static buffer containing day of week string.
106 char *DayOfWeek(unsigned int year
, unsigned int month
, unsigned int day
);
109 * Returns current timestamp.
111 * \param Date Storage for date time structure.
115 void GSM_GetCurrentDateTime(GSM_DateTime
* Date
);
118 * Converts \ref GSM_DateTime to time_t.
120 * \param DT Input timestamp.
122 * \return time_t value.
126 time_t Fill_Time_T(GSM_DateTime DT
);
129 * Returns the local timezone offset in seconds.
130 * For example 7200 for CEST.
132 * \return Timezone offset seconds.
136 int GSM_GetLocalTimezoneOffset(void);
139 * Converts time_t to gammu \ref GSM_DateTime structure.
141 * \param Date Storage for date.
142 * \param timet Input date.
146 void Fill_GSM_DateTime(GSM_DateTime
* Date
, time_t timet
);
149 * Converts string (seconds since epoch) to gammu \ref GSM_DateTime structure.
151 * \param Date Storage for date.
152 * \param str Input date.
156 void GSM_DateTimeFromTimestamp(GSM_DateTime
*Date
, const char *str
);
159 * Converts gammu \ref GSM_DateTime structure to string (seconds since epoch).
162 * \param str Strorage for string.
166 void GSM_DateTimeToTimestamp(GSM_DateTime
*Date
, char *str
);
169 * Converts timestamp to string according to OS settings.
171 * \param dt Input timestamp.
172 * \param TimeZone Whether to include time zone.
174 * \return Pointer to static buffer containing string.
178 char *OSDateTime(GSM_DateTime dt
, gboolean TimeZone
);
181 * Converts date from timestamp to string according to OS settings.
183 * \param dt Input timestamp.
185 * \return Pointer to static buffer containing string.
189 char *OSDate(GSM_DateTime dt
);
192 * Checks whether date is valid. This does not check time, see
193 * \ref CheckTime for this.
195 * \param date Structure where to check date.
197 * \return True if date is correct.
201 gboolean
CheckDate(GSM_DateTime
* date
);
204 * Checks whether time is valid. This does not check date, see
205 * \ref CheckDate for this.
207 * \param date Structure where to check time.
209 * \return True if time is correct.
213 gboolean
CheckTime(GSM_DateTime
* date
);
216 * Reads date and time from phone.
218 * \param s State machine pointer.
219 * \param date_time Storage for date.
225 GSM_Error
GSM_GetDateTime(GSM_StateMachine
* s
, GSM_DateTime
* date_time
);
228 * Sets date and time in phone.
230 * \param s State machine pointer.
231 * \param date_time Date to set.
237 GSM_Error
GSM_SetDateTime(GSM_StateMachine
* s
, GSM_DateTime
* date_time
);
240 /* Editor configuration
241 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: