Skip to content

Instantly share code, notes, and snippets.

View Suppenterrine's full-sized avatar
🌿
I can't. I have plants tonight.

Lukas Baumert Suppenterrine

🌿
I can't. I have plants tonight.
View GitHub Profile
@Suppenterrine
Suppenterrine / getMonthsAndDays.js
Last active February 18, 2022 23:56
Get MySQL formatted dates and month strings from past months (dynamic)
let diff_dt_now = new Date();
let diff_dt_const = new Date('2020-12-31');
// delta between current month and 2020-12-31 (integer)
let month_diff = (diff_dt_const.getTime() - diff_dt_now.getTime()) / 1000;
month_diff /= (60 * 60 * 24 * 7 * 4);
month_diff = Math.abs(Math.round(month_diff));
class Month {
constructor (range) {
@Suppenterrine
Suppenterrine / FirstAndLastDayFromMonth.js
Last active August 24, 2023 12:46
JS Date from today and with the first and the last day of the specified month
const fs = require('fs');
class MonthRange {
/**
* @param {number} range - Range of months.
* @param {string} language - Language code.
* @param {string} hemisphere - Hemisphere.
* @param {Date} startDate - Start date.
* @param {Date} endDate - End date.
* @returns {object} - Object with month details.