'use strict';

const index = require('../../../../../../@date-fns_tz@1.4.1/node_modules/@date-fns/tz/date/index.cjs');
require('../../../../../../@date-fns_tz@1.4.1/node_modules/@date-fns/tz/date/mini.cjs');

/**
 * Convert a {@link Date} or {@link TZDate} instance to the given time zone.
 * Reuses the same instance when it is already a {@link TZDate} using the target
 * time zone to avoid extra allocations.
 */
function toTimeZone(date, timeZone) {
    if (date instanceof index.TZDate && date.timeZone === timeZone) {
        return date;
    }
    return new index.TZDate(date, timeZone);
}

exports.toTimeZone = toTimeZone;
