From mboxrd@z Thu Jan  1 00:00:00 1970
From: Randomcoder <randomcoder1@gmail.com>
Subject: Re: [proposal] timezone-aware timestamps enhancement
Date: Fri, 20 Mar 2015 11:40:09 +0200
Message-ID: <20150320094009.GC7494@xw>
References: <20150318081355.GH19138@xw>
	<87r3sm6z9z.fsf@delle7240.chemeng.ucl.ac.uk>
	<m2sid2i3dw.fsf@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60694)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <randomcoder1@gmail.com>) id 1YYtPg-0000OW-LA
	for emacs-orgmode@gnu.org; Fri, 20 Mar 2015 05:40:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <randomcoder1@gmail.com>) id 1YYtPd-00088A-E4
	for emacs-orgmode@gnu.org; Fri, 20 Mar 2015 05:40:20 -0400
Received: from mail-we0-x229.google.com ([2a00:1450:400c:c03::229]:34586)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <randomcoder1@gmail.com>) id 1YYtPd-000885-6w
	for emacs-orgmode@gnu.org; Fri, 20 Mar 2015 05:40:17 -0400
Received: by wegp1 with SMTP id p1so77599618weg.1
	for <emacs-orgmode@gnu.org>; Fri, 20 Mar 2015 02:40:16 -0700 (PDT)
Content-Disposition: inline
In-Reply-To: <m2sid2i3dw.fsf@gmail.com>
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
To: Ken Mankoff <mankoff@gmail.com>
Cc: emacs-orgmode@gnu.org

On Wed, Mar 18, 2015 at 02:09:31PM -0400, Ken Mankoff wrote:
> I have a solution that works quite well outside of Org. Apple Calendar
> supports timezones plus a "floating" option.  I use Org for all my
> floating events - local to the computer and me, whatever TZ we're in. I
> haven't found a way to put TZ-specific events into Org.
> 
> If scheduling a Skype with someone in NZ, I enter it in iCal at the NZ
> time in the NZ timezone. Org pulls in my iCal events. Then wherever I
> am when that event happens, I get the alert at the correct time. Most
> things are local to me, so I use "floating" and stay in Org.

I wrote a silly elisp function that does the conversion for me.  Hah,
yeah ! exactly, I use it for the exact same thing, scheduling an interview
with someone on the other side of the planet.

So for example they ask me 

"Can you provide us with times when you're available for an interview ?"
and I just make a table and let them decide when:

    | time Tokyo         | time Sofia             |
    |--------------------+------------------------|
    | <2015-03-20 18:00> | <2015-03-20 Fri 11:00> |
    | <2015-03-21 14:00> | <2015-03-21 Sat 07:00> |
    | <2015-03-22 14:00> | <2015-03-22 Sun 07:00> |
    | <2015-03-23 14:00> | <2015-03-23 Mon 07:00> |
    | <2015-03-24 14:00> | <2015-03-24 Tue 07:00> |
    #+TBLFM: $1='(concat "<" (org-tz-conv $2 "Asia/Tokyo" "to") ">")

You said above you're using iCal (do you mean, Google Calendar or
Apple Calendar?). I'd be interested in setting this up as well, which one
should I be using ?

At this point in time I'm using Org-Mode's agenda to view events.
Should I try to sync them up with my phone and if so what is the recommended
way to go ?



This is the implementation of org-tz-conv:

    (defun org-tz-conv (stamp tz way)
      (let* (
             (current-tz-offset (shell-command-to-string "date +%z"))
             (stamp1    (concat (replace-regexp-in-string "[<>]" "" stamp) " " current-tz-offset))
             (date-cmd-p0  "TZ=%s date -d \"%s\"")
             (date-cmd-p1  "date --date=\"TZ=\\\"%s\\\" %s\"")
             (date-cmd-p2  " +\"%F %H:%M\"")
             (date-cmd-rendered1  (format date-cmd-p1 tz stamp1 ))
             (date-cmd-from  (concat date-cmd-rendered1 date-cmd-p2))
             (date-cmd-to    (concat (format date-cmd-p0 tz stamp1) date-cmd-p2))
             
             (shell-result-from (shell-command-to-string date-cmd-from ))
             (shell-result-to   (shell-command-to-string date-cmd-to   ))

             (result-from (replace-regexp-in-string "\n" "" shell-result-from) )
             (result-to   (replace-regexp-in-string "\n" "" shell-result-to  ) )
             )
        (message shell-result-from)
        (message shell-result-to)
        (cond ((string-equal way "from") result-from)
              ((string-equal way "to"  ) result-to  ))
        ))