Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'View upcoming events on multiple Unix calendars' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
View upcoming events on multiple Unix calendars
Authored by: ratpH1nk on May 15, '06 09:44:58AM
I like the way you gus ahve done this. I may switch, but in the meantime, this is how I have mine setup. It is in my .profile file:

echo 'Today in history:'
cat /usr/share/calendar/* | grep `date +"%m/%d"`


Gets the job done nicely.

[ Reply to This | # ]
View upcoming events on multiple Unix calendars
Authored by: oink on May 15, '06 10:22:29AM

Nice! I modified it slightly:
at /usr/share/calendar/calendar* | grep `date +"%m/%d"`

To avoid the cat directory error:
cat: /usr/share/calendar/de_DE.ISO8859-1: Is a directory
...

It will definitely go into my .profile or my .login

---
blurred visionary



[ Reply to This | # ]
View upcoming events on multiple Unix calendars
Authored by: kenahoo on May 15, '06 10:39:57AM

That's a nice hint - I do have to point out the UUOC, though; you can simplify the command to this:

grep -h `date +"%m/%d"` /usr/share/calendar/ca*

-Ken



[ Reply to This | # ]
The Ruby version
Authored by: Lectrick on May 15, '06 12:25:43PM
I made this a Ruby script to iterate through the next 7 days of holidays. (Strangely, Memorial Day is not listed??) Save as something like "calendar.rb" and make executable (chmod +x calendar.rb) and run... The reason I commented out the alternate "date" code is because I wanted a solution that didn't depend on any include/requires (even though "date" is part of the standard lib...)

#!/usr/bin/env ruby
#require 'date'
#command = "Date.today.upto(Date.today+7){|d| p d.strftime("%m/%d")}

calendars = [ "christian", "computer", "history", "usholiday" ]

0.upto(7) { |d|
for cal in calendars do
out = `grep -h "#{(Time.now+(3600*24*d)).strftime("%m/%d")}" /usr/share/calendar/calendar.#{cal}`
puts out unless out == ""
end
}

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]

View upcoming events on multiple Unix calendars
Authored by: ZZamboni on May 15, '06 12:05:56PM
While this works for most cases, it fails for the more complex date specifications that calendar understands. For example:
% % grep -v '[0-9][0-9]/[0-9][0-9]' /usr/share/calendar.* | less
calendar.australia:Mar 18       Canberra Day (ACT)
   (textual month specification)
calendar.australia:8/MonFirst   Bank Holiday (ACT, NSW)
   ("first monday of the month")
calendar.christian:Easter-46    Ash Wednesday (First day of Lent)
calendar.christian:Easter-7     Palm Sunday (7 days before Easter)
   (Easter-relative dates)
It also ignores multi-line specifications:
01/28   Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
        killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
        1986 


[ Reply to This | # ]