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.
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:
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.
@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
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
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
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!
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/)