Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different results of readstat_get_modified_time on Windows and Mac #278

Open
vonknio opened this issue Jul 18, 2022 · 1 comment
Open

Different results of readstat_get_modified_time on Windows and Mac #278

vonknio opened this issue Jul 18, 2022 · 1 comment
Labels

Comments

@vonknio
Copy link

vonknio commented Jul 18, 2022

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

@evanmiller
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants