Vanilla.PDF  2.0.0
Cross-platform toolkit for creating and modifying PDF documents
Print date
error_type process_date(DateHandle* obj, int nested) {
integer_type year = 0;
integer_type month = 0;
integer_type day = 0;
integer_type hour = 0;
integer_type minute = 0;
integer_type second = 0;
TimezoneType timezone;
integer_type hour_offset = 0;
integer_type minute_offset = 0;
print_spaces(nested);
print_text("Date begin\n");
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetYear(obj, &year));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetMonth(obj, &month));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetDay(obj, &day));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetHour(obj, &hour));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetMinute(obj, &minute));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetSecond(obj, &second));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetTimezone(obj, &timezone));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetHourOffset(obj, &hour_offset));
RETURN_ERROR_IF_NOT_SUCCESS(Date_GetMinuteOffset(obj, &minute_offset));
print_spaces(nested + 1);
if (timezone == TimezoneType_UTC) {
print_text("%04d-%02d-%02d %02d:%02d:%02dZ\n",
year, month, day,
hour, minute, second);
} else {
char timezone_character;
if (timezone == TimezoneType_Later) {
timezone_character = '+';
} else if (timezone == TimezoneType_Earlier) {
timezone_character = '-';
} else {
print_text("Timezone is neither UTC, Earlier nor later\n");
return VANILLAPDF_TEST_ERROR_FAILURE;
}
print_text("%04d-%02d-%02d %02d:%02d:%02d %c%02d:%02d\n",
year, month, day,
hour, minute, second,
timezone_character, hour_offset, minute_offset);
}
print_spaces(nested);
print_text("Date end\n");
return VANILLAPDF_TEST_ERROR_SUCCESS;
}