<commit_before>import * as assert from "assert";
import * as moment from "moment";
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil";

import {
    RavenErrorType,
    GetNextOperationIdCommand,
    IDocumentStore,
    PutDocumentCommand,
} from "../../src";
import { DateUtil } from "../../src/Utility/DateUtil";
import { GetDocumentsCommand } from "../../src/Documents/Commands/GetDocumentsCommand";
import { StringUtil } from "../../src/Utility/StringUtil";

const LOCAL_TIMEZONE_OFFSET = -(new Date().getTimezoneOffset()); // getTimezoneOffset() returns reversed offset
const LOCAL_TIMEZONE_OFFSET_HOURS = LOCAL_TIMEZONE_OFFSET / 60;
const LOCAL_TIMEZONE_STRING =
    // tslint:disable-next-line:max-line-length
    `${LOCAL_TIMEZONE_OFFSET >= 0 ? "+" : "-"}${StringUtil.leftPad(LOCAL_TIMEZONE_OFFSET_HOURS.toString(), 2, "0")}:00`;

describe("DateUtil", function () {

    describe("without timezones", function () {

        it("should properly parse & format date (without UTC dates)", async function () {
            const dateUtil = new DateUtil({
                withTimezone: false
            });
            const date = moment("2018-10-15T09:46:28.306").toDate();
            const stringified = dateUtil.stringify(date);
            assert.strictEqual(stringified, "2018-10-15T09:46:28.3060000");

            const parsed = dateUtil.parse(stringified);
            assert.strictEqual(parsed.getHours(), date.getHours());
            assert.strictEqual(parsed.toISOString(), date.toISOString());
        });

        it("should properly format regular date using UTC dates", async function () {
            const dateUtil = new DateUtil({
                withTimezone: false,
                useUtcDates: true<commit_msg>make utc dates tests insusceptible to DST<commit_after>import * as assert from "assert";
import * as moment from "moment";
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil";

import {
    RavenErrorType,
    GetNextOperationIdCommand,
    IDocumentStore,
    PutDocumentCommand,
} from "../../src";
import { DateUtil } from "../../src/Utility/DateUtil";
import { GetDocumentsCommand } from "../../src/Documents/Commands/GetDocumentsCommand";
import { StringUtil } from "../../src/Utility/StringUtil";

// getTimezoneOffset() returns reversed offset, hence the "-"
const LOCAL_TIMEZONE_OFFSET = -(new Date(2018, 7, 1).getTimezoneOffset()); 
const LOCAL_TIMEZONE_OFFSET_HOURS = LOCAL_TIMEZONE_OFFSET / 60;
const LOCAL_TIMEZONE_STRING =
    // tslint:disable-next-line:max-line-length
    `${LOCAL_TIMEZONE_OFFSET >= 0 ? "+" : "-"}${StringUtil.leftPad(LOCAL_TIMEZONE_OFFSET_HOURS.toString(), 2, "0")}:00`;

describe("DateUtil", function () {

    describe("without timezones", function () {

        it("should properly parse & format date (without UTC dates)", async function () {
            const dateUtil = new DateUtil({
                withTimezone: false
            });
            const date = moment("2018-10-15T09:46:28.306").toDate();
            const stringified = dateUtil.stringify(date);
            assert.strictEqual(stringified, "2018-10-15T09:46:28.3060000");

            const parsed = dateUtil.parse(stringified);
            assert.strictEqual(parsed.getHours(), date.getHours());
            assert.strictEqual(parsed.toISOString(), date.toISOString());
        });

        it("should properly format regular date using UTC dates", async function () {
            const dateUtil = new DateUtil({
                withTimezone: false,
                useUtcDates: true
{'fraction_non_alphanumeric': 0.13430330162283155, 'fraction_numerical': 0.026860660324566313, 'mean_word_length': 3.1377314814814814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4192244', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1009, 'n_words': 225}