Skip to content

Refactor the code to not be dependant on day.js #2

@DevVali

Description

@DevVali

Task: Use built-in JavaScript functions to calculate the date. As this is just a refactor of the code, it should perform just as with day.js. Changing the structure is fine, although the structure can remain as is. Here is the unfinished snippet I have:

const vscode = require('vscode');
const dayjs = require('dayjs');
const { yourXmas } = vscode.workspace.getConfiguration('xmasTime');

// Helpers

/**
 * @param {string} targetDate
 * @returns {{ ms: number, days: number, hours: number, minutes: number}}
 */
function getDifference(targetDate) {
    // ...

    return {
        ms: diffMs,
        days: diffDays,
        hours: diffHours,
        minutes: diffMinutes,
    };
}

function getUnit(difference) {
    // ...
}

// Get the time left and return the text

function getTimeLeft() {
    // ...
}

module.exports = { getTimeLeft };

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions