WizardMac/ReadStat

Different results of readstat_get_modified_time on Windows and Mac

vonknio opened this issue · 1 comments

The result of calling readstat_get_modified_time on the same file is different for Windows and Mac. The code for both platforms is as follows:

#include "readstat.h"

struct Context {
    time_t mdate = 0;
};

int handle_metadata(readstat_metadata_t *metadata, void *ctx) {
    Context* context = (Context*)ctx;

    context->mdate = readstat_get_modified_time(metadata);

    return READSTAT_HANDLER_OK;
}

int main(int argc, char *argv[]) {
    if (argc != 2) {
        printf("Usage: %s <filename>\n", argv[0]);
        return 1;
    }

    Context context{};
    readstat_error_t error = READSTAT_OK;
    readstat_parser_t *parser = readstat_parser_init();
    readstat_set_metadata_handler(parser, handle_metadata);

    error = readstat_parse_dta(parser, argv[1], &context);

    readstat_parser_free(parser);

    if (error != READSTAT_OK) {
        printf("Error processing %s: %d\n", argv[1], error);
        return 1;
    }
    printf("Modified date: %ld\n", context.mdate);
    return 0;
}

The output on Windows is:

Modified date: 1031073900

...while the output on Mac is:

Modified date: 1031048700

I'm attaching the sample file. Tested with Readstat 1.1.8.
citytemp.dta.zip

Hi, these two values appear differ by exactly 7 hours. I am guessing it is a time zone issue. Is this difference important?