Coder Social home page Coder Social logo

Comments (3)

hauselin avatar hauselin commented on June 19, 2024 1

Hi @technicalpickles, thanks for letting me know. I've just fixed it.

Cool vault name, btw! ;)

from obsidian-alfred.

technicalpickles avatar technicalpickles commented on June 19, 2024 1

Awesome, thanks! I had worked out a solution at about the same time, but without knowing about padStart 😅

from obsidian-alfred.

hauselin avatar hauselin commented on June 19, 2024

Also, if it's easier, in the osascript for today's note, you can simply replace the code after //don't need to edit the lines below with the code below. Other aspects of the workflow haven't changed.

// don't need to edit the lines below
date_format = date_format.toLowerCase();

// determine no. of y, m, d needed
n_y = date_format.split('y').length - 1;
n_m = date_format.split('m').length - 1;
n_d = date_format.split('d').length - 1;
y_char = "y".repeat(n_y);
m_char = "m".repeat(n_m);
d_char = "d".repeat(n_d);

// get today's date
today = new Date();
yyyy = today.getFullYear().toString();
mm = (today.getMonth() + 1).toString();
dd = today.getDate().toString();

// format date according to user specification (e.g., yy, m, d)
yyyy = yyyy.slice(4-n_y, 4);
if (mm.length == 1) {mm = mm.padStart(2, '0').slice(2-n_m, 2)};
if (dd.length == 1) {dd = dd.padStart(2, '0').slice(2-n_d, 2)};

date_format = date_format.replace(y_char, yyyy);
date_format = date_format.replace(m_char, mm);
date_format = date_format.replace(d_char, dd);

p = encodeURIComponent(v) + "&file=" + date_format + ".md";
uri = "obsidian://open?vault=" + p;

// get the current app to access the standard additions
app = Application.currentApplication();
app.includeStandardAdditions = true;

// open file in vault
app.openLocation(uri);
console.log(uri);

from obsidian-alfred.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.