Calendar and tasks for daily notes

Hi @asun, glad you found it helpful. I made a quick update to allow insertion of the ordinal suffix by adding XX into the template string right after the day number (%d or %e etc.). See if it works for you - the default version in the gist has this in as an example.

I made a few other quick updates based on @Mike’s suggestions:

  • outputFile specifies the output filename, can be either a relative (just filename like calendar.md) or a full path
  • hlt provides the string to use for highlighting today’s date, e.g. ==

Note about the day number. You can use %e but that pads 1-digit numbers with a space. If you want the one digit day number without a leading zero you can use %-d

when I have more time I’ll come back to the other ideas.


Yep, also interested. Is there a way of linking that I didn’t notice and that doesn’t create backlinks?

See my reply to RyanWu :point_up:

2 Likes

Thanks :slight_smile:

Any way how to make it not depended on fixed naming convention?
I just edit script and add my ISO date formating and script should extract all the parts like: date, month day, a rebuild the note name when creating calendar.

I tried to edit current script with my ISO formatting:

linkformat="%ww' %DD-%MMM (%ddd) %Y"

But it create empty calendar.

how can I run it in Windows? :flushed:

1 Like

@jcperezh Because it uses date or gdate it will not run on windows natively. That are utilities only available on linux (or OSX)

You could try to install the Ubuntu (command line) from the windows store and run it from there.

Yes…that is what I did.

done! work great. im now trying to translate it to german (doesn’t work when the linux language is not English) this is my first attempt with .sh and i am trying to change the “Mon” and “Sun” with $hMon and $hSun so i can just translate the headers. not successful yet.

1 Like

@jcperezh That’s weird your approach should work. You have to change the other occurrences if “Mon” and “Sun” as well later in the code.

You are right, the language of the date command changes with the system language.
This can be prevented running the script a temporary environmental variable:

LANG=en_US ./md-cal.sh

Note: Don’t for get to make the script executable first: chmod +x ./md-cal.sh

done! i don’t know the syntax yet and didn’t use “$hSun”, just $hSun without the quotation marks :flushed: :roll_eyes:. it work perfect.

Edit: Now it is getting interesting, Week number in Europa and in USA are not the same…
Edit_2: %V instead of %W solved it (ISO Standard)


I created a link also to my Week-Note to the Week Number

3 Likes

Python script version (customizable) with KB script makro script!

4 Likes

I think it’s because the link is in a table. If you escape the pipe, it’s not gonna show: [[20200604\|4]] in preview mode.

Looks like a great change for the people in Europe :grinning:.
Would you mind sharing it?

Hi guys, I really want something like that. Sorry if the question is to stupid. I dont have any knolowge with this, but Im trying anyway to make this work here on Window. Can anyone help me?
I did these steps:

  • installed Ubuntu Command Line from windows store as suggested;
  • installed Windows Subsystem for Linux (WL2)
  • Set the startDate, endDate and dailyNotePath on script
  • Tried to execute md-cal.sh and got this:
    md-cal.sh: 96: function: not found
    md-cal.sh: 1: gdate: not found
    md-cal.sh: 105: Bad substitution

Can someone point me to some direction to solve this?
Thanks

on Linux u need to use “date” instead of gdate Screenshot_20200927-110219_File Manager +|690x140

1 Like

Thanks! My bad. I forgot that I was kind of using Linux on Windows

Did you get it to work?

Might interest you too: I wrote some Python that generates a note for each week with the daily notes of that week already transcluded.

Want to use that for my weekly review and have them directly linked in my calendar note

def getDatesfromWeek(year,week): # create list of isoformat dates for a given year & week 
    firstdayofweek = datetime.datetime.strptime(f'{year}-W{week - 1}-1', "%Y-W%W-%w").date()
    dates = []
    for i in range(7):
        date = firstdayofweek + datetime.timedelta(days=i)
        dates.append(date.isoformat())
    return dates

days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

path_folder="C:\\Users\{Username}\{Folder}" 

for i in range(53):
    dates = getDatesfromWeek('2020',i+1) # get list of dates for the week
    
    m = "" # create empty string
    for j in range(len(days)): # go through number of days in each week
        n = "## " + days[j] + ", " + dates[j] + "\n\n" + "![[" + dates[j] + "]]" + "\n\n" # create heading and transcluded daily note
        m += n # add to note for the week
        
    filename = "{}\\2020-W{}.md".format(path_folder, i+1) # create filename based on week
    with open(filename, 'w') as f: 
        f.write(m) # write text to file 
6 Likes

Hi @juen!
Actually I haven’t been able to make it work yet. I realized that I know very little about the subject to know what I don’t know yet. hahaha
I solved only the error “gdate: not found”, but I didn’t have time to read the documentation more calmly and solve the other 2. So I decided to postpone the implementation of the calendar here.
As soon as I get some time to return to my calendar, I will test your code. Thank you very much for the suggestion! :slight_smile:

Actually, I got the shell script from @jcperezh and modified it to fit my daily note format (“daily notes/2020-10-07”). I generated the calendar file with all the right backlinks with it on Windows. If you want I’ll send you the modified script, you just need to enable Linux subsystem on Windows and install Ubuntu for Windows to run it (https://techviral.net/run-bash-windows-10/)