<commit_before>#include "parse.h"
#include "qstring.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

void parse_request(router_request_t *req, tdata_t *tdata, HashGrid *hg, int opt, char *optarg) {
    const char delim[2] = ",";
    char *token;

    switch (opt) {
    case 'a':
        req->arrive_by = true;
        break;
    case 'd':
        req->arrive_by = false;
        break;
    case 'r':
        srand(time(NULL));
        router_request_randomize(req);
        break;
    case 'D':
        {
            struct tm ltm;
            memset (&ltm, 0, sizeof(struct tm));
            strptime (optarg, "%Y-%m-%dT%H:%M:%S", &ltm);
            router_request_from_epoch (req, tdata, mktime(&ltm)); // from struct_tm instead?
        }
        break;
    case 'f':
        req->from = strtol(optarg, NULL, 10);
        break;
    case 't':
        req->to = strtol(optarg, NULL, 10);
        break;
    case 'V':
        req->via = strtol(optarg, NULL, 10);
        break;
    case 's':
        req->walk_slack = strtol(optarg, NULL, 10);
        break;
    case 'S':
        req->walk_speed = strtod(optarg, NULL);
        break;
    case 'o':
        req->optimise = 0;
        token = strtok(optarg, delim);

        while ( token != NULL ) {
            if (strcmp(token, "shortest")  == 0) req->optimise |= o_shortest;
            if (strcmp(token, "transfers") == 0) req->optimise |= o_transfers;<commit_msg>Fix daylight saving time issue in parsing<commit_after>#include "parse.h"
#include "qstring.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

void parse_request(router_request_t *req, tdata_t *tdata, HashGrid *hg, int opt, char *optarg) {
    const char delim[2] = ",";
    char *token;

    switch (opt) {
    case 'a':
        req->arrive_by = true;
        break;
    case 'd':
        req->arrive_by = false;
        break;
    case 'r':
        srand(time(NULL));
        router_request_randomize(req);
        break;
    case 'D':
        {
            struct tm ltm;
            memset (&ltm, 0, sizeof(struct tm));
            strptime (optarg, "%Y-%m-%dT%H:%M:%S", &ltm);
            ltm.tm_isdst = -1;
            router_request_from_epoch (req, tdata, mktime(&ltm)); // from struct_tm instead?
        }
        break;
    case 'f':
        req->from = strtol(optarg, NULL, 10);
        break;
    case 't':
        req->to = strtol(optarg, NULL, 10);
        break;
    case 'V':
        req->via = strtol(optarg, NULL, 10);
        break;
    case 's':
        req->walk_slack = strtol(optarg, NULL, 10);
        break;
    case 'S':
        req->walk_speed = strtod(optarg, NULL);
        break;
    case 'o':
        req->optimise = 0;
        token = strtok(optarg, delim);

        while ( token != NULL ) {
            if (strcmp(token, "shortest")  == 0) req->optimise |= o_shortest;
            if (strcmp(token, "transfers") == 0) req->optimise |= o_transfers;
{'fraction_non_alphanumeric': 0.15369059656218403, 'fraction_numerical': 0.00910010111223458, 'mean_word_length': 2.0224032586558045, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3028415', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1036, 'n_words': 253}