statusInvestFunctions

Fornece funçoes de ajuda nos scripts

Detta skript bör inte installeras direkt. Det är ett bibliotek för andra skript att inkludera med meta-direktivet // @require https://update.greasyfork.org/scripts/477957/1268273/statusInvestFunctions.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         statusInvestFunctions
// @namespace    http://tampermonkey.net/
// @version      0.03
// @description  Fornece funçoes de ajuda nos scripts
// @author       @josias-soares
// @license      MIT
// ==/UserScript==

function calcularDiasDecorridos(dataFornecida) {

    // Hoje
    const hoje = new Date();

    // Converte a data fornecida para um objeto Date
    const dataFornecidaDate = new Date(dataFornecida);

    // Calcula a diferença em milissegundos
    const diferencaEmMilissegundos = dataFornecidaDate - hoje;

    // Converte a diferença em dias
    const diasDecorridos = Math.floor(diferencaEmMilissegundos / (1000 * 60 * 60 * 24));

    return diasDecorridos;
}

function getDataHojeFormatada(){
    // Hoje
    const hoje = new Date();

    // Obtém o ano, mês e dia da data atual
    const ano = hoje.getFullYear();
    const mes = String(hoje.getMonth() + 1).padStart(2, '0'); // O mês é baseado em zero (janeiro = 0)
    const dia = String(hoje.getDate()).padStart(2, '0');

    // Cria a string no formato 'YYYY-MM-DD'
    return `${ano}-${mes}-${dia}`;
}