Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/sas/readstat_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ static readstat_charset_entry_t _charset_table[] = {
{ .code = 248, .name = "SHIFT_JISX0213" },
};

static time_t sas_epoch() {
return - 3653 * 86400; // seconds between 01-01-1960 and 01-01-1970
}

static time_t sas_convert_time(double time, time_t epoch) {
time += epoch;
if (isnan(time))
Expand Down Expand Up @@ -159,8 +163,7 @@ readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *hinfo,
sas_header_end_t header_end;
int retval = READSTAT_OK;
char error_buf[1024];
struct tm epoch_tm = { .tm_year = 60, .tm_mday = 1 };
time_t epoch = mktime(&epoch_tm);
time_t epoch = sas_epoch();

if (io->read(&header_start, sizeof(sas_header_start_t), io->io_ctx) < sizeof(sas_header_start_t)) {
retval = READSTAT_ERROR_READ;
Expand Down Expand Up @@ -338,8 +341,7 @@ readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *hinfo,

readstat_error_t sas_write_header(readstat_writer_t *writer, sas_header_info_t *hinfo, sas_header_start_t header_start) {
readstat_error_t retval = READSTAT_OK;
struct tm epoch_tm = { .tm_year = 60, .tm_mday = 1 };
time_t epoch = mktime(&epoch_tm);
time_t epoch = sas_epoch();

memset(header_start.table_name, ' ', sizeof(header_start.table_name));

Expand Down