emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org google weather


From: Nick Dokos
Subject: Re: [O] org google weather
Date: Fri, 04 Mar 2011 11:38:01 -0500

Ian Barton <address@hidden> wrote:

> 
> > Hi Ian,
> >
> > Ian Barton wrote:
> >>> Has anybody tried adding the functionality of %%(diary-sunrise-sunset)
> >>> (sunrise, sunset time and daylight hours) to the google weather code?
> >>
> >> I just have something like:
> >>
> >> #+CATEGORY: Day/Year
> >> &%%(diary-day-of-year)
> >> #+CATEGORY: Sunrise
> >> &%%(diary-sunrise-sunset)
> >>
> >> in one of my Agenda files. Sunrise then appears at sunrise time in my 
> >> Agenda
> >> like:
> >>
> >>     Sunrise:     6:53...... Sunrise (GMT), sunset 5:52pm (GMT) at
> >> Wilkesley (10:58 hours daylight)
> >
> > Do you have a way to get the sunset located on a line on its own (different
> > line from the sunrise one)?  That'd be even much nicer...
> >
> No, but I would like one:) If there were separate diary functions for
> sunrise and sunset it would be easy. Maybe I need to look at the diary
> elisp and write my own separate functions.
> 

Quick hack just parsing the output of diary-sunrise-sunset.

I added this early in my org-config file (which is sourced by .emacs)
- modify latitude, longitude to taste:

--8<---------------cut here---------------start------------->8---
;;; diary supplement - rich in Ca
(setq calendar-latitude 42.3)
(setq calendar-longitude -71.0)
(defun diary-sunrise ()
  (let ((dss (diary-sunrise-sunset)))
    (with-temp-buffer
      (insert dss)
      (goto-char (point-min))
      (search-forward ",")
      (buffer-substring (point-min) (match-beginning 0)))))

(defun diary-sunset ()
  (let ((dss (diary-sunrise-sunset))
        start end)
    (with-temp-buffer
      (insert dss)
      (goto-char (point-min))
      (search-forward ", ")
      (setq start (match-end 0))
      (search-forward " at")
      (setq end (match-beginning 0))
      (goto-char start)
      (capitalize-word 1)
      (buffer-substring start end))))
--8<---------------cut here---------------end--------------->8---

and this to one of my agenda files:

--8<---------------cut here---------------start------------->8---
#+CATEGORY: Weather
%%(diary-sunrise)
%%(diary-sunset)
--8<---------------cut here---------------end--------------->8---

and I get:

,----
| Friday      4 March 2011
|   Weather:     6:16...... Sunrise (EST)
|                8:00...... ----------------
|               10:00...... ----------------
|               12:00...... ----------------
|               14:00...... ----------------
|               16:00...... ----------------
|   Weather:    17:36...... Sunset (EST)
|               18:00...... ----------------
|               20:00...... ----------------
`----

Nick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]