Pe8er/Sidebar.Widget

Calendar issues

Opened this issue · 4 comments

Date is messed up/2 days off
Next month dates scattered throughout the month (If next month dates turned on)
Blank space between day 21 and 22 (if next month dates turned off)
15 day of month appears as "_1_5"
No 19 and 20 days, only the number one
screen shot 2018-01-15 at 11 07 51 am

Having the same issue. However, doesn't seem like there's going to be a solution for it any time soon :(

itho commented

I've written a fix but I'm short on time so haven't tested for other months yet (which hopefully don't matter). The fix works by collecting more characters from the previous line and then trimming the trailing whitespace. I'm not sure why underscores were in there but I've removed those also.

Monday = 'cal | awk \'{ \
  print " "$0; \
  getline; \
  print "Mo Tu We Th Fr Sa Su"; \
  getline; \
  if (substr($0,1,2) == " 1") \
    print "                    1 "; \
  do { \
    prevline=$0; \
    if (getline == 0) exit; \
    prev=substr(prevline,4,21); \
    sub(/ *$/, "", prev); \
    gsub(/_/, "", prev); \
    print " " prev " " substr($0,1,2) " "; \
  } while (1) }\' \
  && date "+%-m %-d %y"'

I also noticed an issue where the unicode backspace character was creeping into the 'day' variable, causing the today highlight to fail. This is a fix to that issue:

for day in days
    day = day.replace(//g, "") # stupid backspace char
    cell = $("<td>#{day}</td>").appendTo(tableRow)
    cell.addClass("today") if day == date

I tried the above and I am still getting the failed underscore issue on the current day. I have my first day of the week set as Sunday as opposed to Monday.

I figured it out, took me about 2 hours. itho had found the issues, but didn't quite correct them right.

Here is the beginning part I edited

Sunday = 'cal -h && date "+%-m %-d %y"'

Monday ='cal -h | awk \'{ print " "$0; getline; print "Mo Tu We Th Fr Sa Su"; \
getline; if (substr($0,1,2) == " 1") print "                    1 "; \
do { prevline=$0; if (getline == 0) exit; print " " \
substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }\' && date "+%-m %-d %y"'

Then here is the bottom part that adds the day variable or kinda lights it up

for day in days
      day = day.replace(/\D/g, '')
      cell = $("<td>#{day}</td>").appendTo(tableRow)
      cell.addClass("today") if day == date

This should be a good fix, or atleast it worked for me! Let me know if you find any other issues with the codes