C_TimeFormats
Overview
Defines formats to read and write different time values.
#include "clingo/lang/expect.h"
#include "clingo/time/C_TimeFormats.h"
#include "clingo/time/cTime.h"
TEMP_SLICE_C_(
test,
{
cTime time;
char const* fmt;
char const* exp;
}
)
#define t_( ... ) ((test){__VA_ARGS__})
int main( void )
{
init_tap_c_();
cTime time = make_time_c( 2006, c_Jan, 2, 15, 4, 5, 0, tz_c( -700 ) );
testSlice tests = slice_c_( test,
// date
t_( time, C_DateFormat, "2006.01.02" ),
// daytime
t_( time, C_KitchenTime, " 3:04PM" ),
// time
t_( time, C_AnsiCTime, "Mon Jan 2 15:04:05 2006" ),
t_( time, C_Rfc882Time, "02 Jan 06 15:04 -0700" ),
t_( time, C_Rfc1123Time, "Mon, 02 Jan 2006 15:04:05 -0700" ),
t_( time, C_Rfc3339Time, "2006-01-02T15:04:05-07:00" ),
t_( time, C_Rfc3339TimeNano, "2006-01-02T15:04:05.0-07:00" )
);
for_each_c_( test const*, t, tests )
{
cRecorder* rec = &recorder_c_( 64 );
bool res = write_time_c( rec, t->time, t->fmt );
res &= recorded_is_c( rec, t->exp );
tap_descf_c( res, "'%s' -> '%s'", t->fmt, turn_into_cstr_c( rec ) );
}
return finish_tap_c_();
}
Types and Definitions
date definitions
C_DateFormat
char const*const C_DateFormat = "YYYY.MM.DD";
The definition of the default format to read or write a cDate value.
C_TextDate
char const*const C_TextDate = "EEE MMM _D YYYY";
The definition to read or write a cDate with some text.
C_IsoDate
char const*const C_IsoDate = "YYYY-MM-DD";
The definition of a format to read or write a cDate value in the ISO format.
C_IsoOrdinalDate
char const*const C_IsoOrdinalDate = "YYYY-CCC";
The definition of a format to read or write a cDate value in the ISO format for ordinal dates.
C_IsoWeekDate
char const*const C_IsoWeekDate = "XXXX-WWW-E";
The definition of a format to read or write a cDate value in the ISO format for week dates.
C_Rfc2822Date
char const*const C_Rfc2822Date = "EEE, DD MMM YYYY";
The definition of a format to read or write a cDate value in the in RFC2822 defined format.
daytime definitions
C_DaytimeFormat
char const*const C_DaytimeFormat = "hh:mm:ss.n";
The definition of the default format to read or write a cDaytime value.
C_IsoDaytime
char const*const C_IsoDaytime = "hh:mm:ss";
The definition of a format to read or write a cDaytime value in the ISO format.
C_KitchenTime
char const*const C_KitchenTime = "_k:mmAP";
The definition of a format to read or write a cDaytime value from a kitchen clock.
duration definitions
C_DurationFormat
char const*const C_DurationFormat = "wdhmsn";
The definition of the default format to read or write a cDuration value.
time definitions
C_TimeFormat
char const*const C_TimeFormat = "YYYY.MM.DD hh:mm:ss oooo";
The definition of the default format to read or write a cTime value.
C_IsoTime
char const*const C_IsoTime = "YYYY-MM-DDThh:mm:ssoooo";
The definition of a format to read or write a cTime value int the ISO format.
C_Rfc2822Time
char const*const C_Rfc2822Time = "EEE, DD MMM YYYY hh:mm:sszzzz";
The definition of a format to read or write a cTime value in the in RFC2822 defined format.
C_AnsiCTime
char const*const C_AnsiCTime = "EEE MMM _D hh:mm:ss YYYY";
The definition of a format to read or write a cTime value in the default format in ANSI C.
C_Rfc882Time
char const*const C_Rfc882Time = "DD MMM YY hh:mm oooo";
The definition of a format to read or write a cTime value in the in RFC882 defined format.
C_Rfc1123Time
char const*const C_Rfc1123Time = "EEE, DD MMM YYYY hh:mm:ss oooo";
The definition of a format to read or write a cTime value in the in RFC1123 defined format.
C_Rfc3339Time
char const*const C_Rfc3339Time = "YYYY-MM-DDThh:mm:sszz";
The definition of a format to read or write a cTime value in the in RFC3339 defined format.
C_Rfc3339TimeNano
char const*const C_Rfc3339TimeNano = "YYYY-MM-DDThh:mm:ss.nzz";
The definition of a format to read or write a cTime value in the in RFC3339 defined format, including the nanoseconds part.