emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: thunk2@arcor.de (Thomas Plass)
To: Matt Price <moptop99@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: parsing time strings from properties
Date: Sun, 22 Sep 2019 12:10:46 +0200	[thread overview]
Message-ID: <23943.18598.271616.396497@AGAME7.local> (raw)
In-Reply-To: Your message of Saturday, September 21 2019 16:27:33 (ID: <CAN_Dec8MJLLQMdOVPxM9bU44CVY0VJF8j=m5VEoXc_numQXy9A@mail.gmail.com>).

Hi,

Matt Price wrote at 16:27 on September 21, 2019:
: 
: :DUE_AT: 2019-09-26
: 
: ...
:
: I'm wondering though how hard
: it would be to get the current time zone -- or the time zone that the course is taught in -- from
: emacs, and construct the string from that value. 

This'll return the offset suffix (if that's what you want) when
executed in your local time zone (presumably "-04:00"):

(defun Price/local-time-offset-from-iso-date (y-m-d)
  (let* ((ymd (mapcar (lambda (s) (string-to-number s)) (split-string y-m-d "-")))
         (offsecs (nth 8
                       (decode-time
                        (apply #'encode-time
                               (list 59 59 23 (nth 2 ymd) (nth 1 ymd) (nth 0 ymd)))))))
    (format "%s%02d:%02d"
            (if (> offsecs 0) "+" "-")
            (/ offsecs 3600)
            (% offsecs 3600))))

On Unix, this'll always work.  On Windows, it works most of the time,
but may fail in the weeks around switches from and to daylight saving.

Thomas

  parent reply	other threads:[~2019-09-22 10:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-21 20:27 parsing time strings from properties Matt Price
2019-09-22  2:54 ` Adam Porter
2019-09-22 10:10 ` Thomas Plass [this message]
2019-09-22 17:18   ` Matt Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23943.18598.271616.396497@AGAME7.local \
    --to=thunk2@arcor.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=moptop99@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).