Daily Jots Generator

linkWelcome Note:

Welcome to the Date List Generator! This tool is designed to help you quickly create a customized list of dates for tagging, logging, or organizing projects. With a few inputs, you can define specific tags, set the number of days, choose a start date, and arrange the dates in either chronological or reverse order, creating a date sequence tailored to your needs.


Whether you're tracking daily updates, managing project timelines, or simply organizing notes, this generator provides a flexible, user-friendly solution to streamline your date management. Simply input your preferences, and the tool will deliver a formatted list of dates that’s ready to use. Enjoy effortless organization and enhanced productivity!


linkDemo:

linkGeneral - Calling the Plugin - Daily Jots Generator



linkDocumentation:

linkHow to:

Call the Plugins using {Daily Jots Generator: List}

Fill in the details in the prompt window. Details give below.

Get the results mentioned below.

linkLet’s walk through a typical usage example:

linkInput Example

Tags: "project-update"

Number of Days: 7

Reverse Chronological Order: Un-checked

Start Date: 01/01/2024

Note: If fields are left blank (e.g., “daily-jots” as the tag, today’s date as the start date, 10 days for number of days, and in chronological order).

linkOutput

If the above inputs are entered, the code will generate a list of seven dates in reverse chronological order, starting from January 1, 2024. Each date will have the tag @~/project-update/ prefixed:

@~/project-update/January 7th, 2024
@~/project-update/January 6th, 2024
@~/project-update/January 5th, 2024
@~/project-update/January 4th, 2024
@~/project-update/January 3rd, 2024
@~/project-update/January 2nd, 2024
@~/project-update/January 1st, 2024

linkTips for Use

Input Validity: Ensure dates are in MM/DD/YYYY format to avoid errors.

Long Lists: For large lists (e.g., 100+ days), consider using chronological order for readability.

Default Settings: Use default tags like "daily-jots" for generic logging purposes; modify the start date and number of days for specific projects.


linkTable - Plugin Parameters:

name

Daily Jots Generator

icon

note_add

description

Gives you a list of dynamic new note creation or existing note linking option, based on few basic inputs.

instructions

Trigger the User Prompt using {Daily Jots Generator: List}, and get the list anywhere in the note.
Daily Jots Generator - Docs


linkCode Base:

{
insertText: {
/**
* Generates a list of formatted dates based on user input for tags, number of days, start date,
* and chronological order. Outputs the dates in the console.
*/
"List": async function (app) {
 
// console.log("Start:");
// Initialize today's date and format it as MM/DD/YYYY for default prompt input.
const today = new Date();
const formattedDate = `${today.getMonth() + 1}/${today.getDate()}/${today.getFullYear()}`;
// console.log("formattedDate:", formattedDate); // Outputs: MM/DD/YYYY
 
// Prompt the user for details to configure the correlation matrix.
const result = await app.prompt("Select details for Generating Daily Jots List", {
inputs: [
{ label: "Select the Tags (Default: daily-jots)", type: "tags", limit: 1 },
{ label: "Select the Number of Days (Default: 10, if left blank)", type: "string" },
{ label: "Reverse Chronological Order (Default: Chronological)", type: "checkbox" },
{ label: "Select the Start Date (MM/DD/YYYY)", type: "string", value: `${formattedDate}` },
]
});
 
// ------- Check if the user has cancelled the operation -------
if (!result) {
// console.log("User cancelled the operation");
app.alert("Operation has been cancelled. Tata! Bye Bye! Cya!");
return;
}
 
// Destructure user input into variables.
const [tagNames, numberDays, chronoSelect, startDatex] = result;
// const [tagNames = "daily-jots", numberDays = "10", chronoSelect = false, startDatex = null] = result;
// console.log("result:", result);
 
// Default tag selection to 'daily-jots' if none provided.
const tagSelect = tagNames || "daily-jots";
// Use startDatex from user input, or default to today if left empty.
const startDate = startDatex ? new Date(startDatex) : today;
// Parse number of days input; defaults to 10 if blank.
const numberOfDays = parseInt(numberDays) || 10;
// Check if the user selected reverse chronological order.
const chronoOrder = chronoSelect;
 
/**
* Generates a list of dates starting from a specified date.
* Dates are formatted with tags and include ordinal suffixes.
*
* @param {Date} startDate - The starting date for date generation.
* @param {number} days - Number of days to generate from startDate.
* @returns {Array} - An array of formatted date strings.
*/
function generateDates(startDate, days) {
const dates = [];
for (let i = 0; i < days; i++) {
// Calculate date by adding i days to the start date.
const date = new Date(startDate);
date.setDate(date.getDate() + i);
 
// Format the date with the tag and add ordinal suffix.
const day = date.getDate();
const suffix = getSuffix(day);
const formattedDate = `@~/${tagSelect}/${date.toLocaleString('en-US', { month: 'long' })} ${day}${suffix}, ${date.getFullYear()}`;
 
dates.push(formattedDate);
}
// Reverse the date order if chronological order is unchecked.
return chronoOrder ? dates : dates.reverse();
}
 
/**
* Determines the appropriate ordinal suffix for a day.
*
* @param {number} day - The day of the month.
* @returns {string} - The ordinal suffix for the day.
*/
function getSuffix(day) {
if (day >= 11 && day <= 13) return 'th';
switch (day % 10) {
case 1: return 'st';
case 2: return 'nd';
case 3: return 'rd';
default: return 'th';
}
}
 
// Generate dates based on the user input.
let dates = generateDates(startDate, numberOfDays);
dates = dates.join('\n');
// console.log(dates);
return dates+`\n`;
}
}
}

linkAdditional Information:


linkChange Log:

October 26th, 2024: Built the basic working skeleton functions and features which I expected. And tested the code.

November 1st, 2024: Added user prompt selections, tag, start date, sorting, number of days. Then made the corrections and bug fixes and limitations. Tested the code.


linkImplemented & Upcoming:

Remove selected tags using ~.

Include tags of interest to broaden the options.

Specify the number of days to generate starting from the selected date.

Implement various sorting options for flexibility in output.

Add user prompt selection for a more intuitive experience.

Conduct thorough testing, fine-tuning, and bug fixes to ensure reliability.

Future Ideas in the Bucket:

Explore additional options to incorporate it here.


Code Explanation! For Curious Readers and Explores! Thank you if you have made till here. You are Awesome, if you are reading this! 😀. Have a Great Day Ahead!


Time Invested For this Plugin: 1h + 2h 30m = 3h 30m [Not including the ideas popping up randomly when doing daily rituals, only Screen Time.]