emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Guido Van Hoecke <guivho@gmail.com>
To: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Problem with Google Calendar Synchronization
Date: Thu, 09 May 2013 20:00:40 +0200	[thread overview]
Message-ID: <m2d2t0xcc7.fsf@gmail.com> (raw)
In-Reply-To: <87ip2sp7u5.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Thu, 9 May 2013 15:05:06 +0100")

[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]

Hi Eric,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Guido Van Hoecke <guivho@gmail.com> writes:
>
>> Eric,
>>
>> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
> [...]
>
>>> Suggestions on how to handle this case would be welcome, of course.
>>
>> I created a patch so that the date and time string is built directly
>> from the iCal data for times before the epoch. This function produces
>> valid date/time strings albeit without weekday info.
>>
>> Patch file is attached.
>
> Excellent.  Thanks for this.  Can you update the file on Worg directly?
> If not, I will try to do it.
>
> One point, however.  Should the first return statement in your
> datetimestring(input) function (see last line in patch excerpt below)
> refer to "input" instead of "datetmp"?  What you have works because of
> all variables being global but is less clear than using the argument, I
> would suggest?

It should be "timestamp" rather than "datetmp" :(

I have attached the corrected patch.

I don't know whether I have access to Worg.
Would you mind updating it?

> Thanks again,

My pleasure,

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ical2org.patch --]
[-- Type: text/x-patch, Size: 3071 bytes --]

--- ical2org.awk.orig	2013-05-09 14:15:14.000000000 +0200
+++ ical2org.awk	2013-05-09 19:52:37.000000000 +0200
@@ -27,7 +27,7 @@
 # no further revision log after this as the file was moved into a git
 # repository...
 #
-# Last change: 2011.01.28 16:08:03
+# Last change: 2013.05.09 19:52:37
 #----------------------------------------------------------------------------------

 # a function to take the iCal formatted date+time, convert it into an
@@ -60,12 +60,31 @@

     # print "adjusted    : " timestamp
     # print "Time stamp  : " strftime("%Y-%m-%d %H:%M", timestamp);
+    if(timestamp < 0) timestamp = 0;
     return timestamp;
 }

+# a function to comvert the iCal date+time string into a date time string;
+# it uses the datetimestamp subroutine to compute the value to feed to strftime;
+# if the iCal date falls before time 0, the string is built from the iCal input;
+
+function datetimestring(input)
+{
+    # try to create datetimestring from the datetimestamp
+    timestamp = datetimestamp(input);
+    if (timestamp > 0)
+        return strftime("%Y-%m-%d %a %H:%M", datetimestamp(timestamp));
+
+    # this is a date before the start of the epoch
+    # create the yyyy-mm-dd hh:mm string from the input (without day of week)
+    datespec = gensub("([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])T([0-9][0-9])([0-9][0-9])([0-9][0-9]).*[\r]*", "\\1-\\2-\\3 \\4:\\5", "g", input);
+    # print "==> datespec:" datespec;
+    return datespec;
+}
+
 BEGIN {
     ### config section
-    max_age =  7; # in days
+    max_age =  -1; #7; # in days
                   # set this to -1 to get all entries or to N>0 to only get
                   # that start or end less than N days ago
     ### end config section
@@ -90,6 +109,7 @@
     indescription = 0;
     lasttimestamp=-1;

+
     print "#+TITLE:     Main Google calendar entries"
     print "#+AUTHOR:    Eric S Fraga"
     print "#+EMAIL:     e.fraga@ucl.ac.uk"
@@ -140,12 +160,12 @@

 /^DTSTART;VALUE=DATE/ {
     datetmp = gensub("([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])(.*[\r])", "\\1T000000\\2", "g", $2)
-    date = strftime("%Y-%m-%d %a %H:%M", datetimestamp(datetmp));
+    date = datetimestring(datetmp);
     if(max_age>0)     lasttimestamp = datetimestamp(datetmp);
 }
 /^DTEND;VALUE=DATE/ {
     datetmp = gensub("([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])(.*[\r])", "\\1T000000\\2", "g", $2)
-    time2 = strftime("%Y-%m-%d %a %H:%M", datetimestamp(datetmp));
+    time2 = datetimestring(datetmp);
     date = date ">--<" time2;
     if(max_age>0)     lasttimestamp = datetimestamp(datetmp);
 }
@@ -154,7 +174,7 @@
 # we ignore the seconds

 /^DTSTART[:;][^V]/ {
-    date = strftime("%Y-%m-%d %a %H:%M", datetimestamp($2));
+    date = datetimestring($2);
     if(max_age>0)     lasttimestamp = datetimestamp($2);
     # print date;
 }
@@ -165,7 +185,7 @@

 /^DTEND[:;][^V]/ {
     # print $0
-    time2 = strftime("%Y-%m-%d %a %H:%M", datetimestamp($2));
+    time2 = datetimestring($2);
     date = date ">--<" time2;
     if(max_age>0)     lasttimestamp = datetimestamp($2);
 }

[-- Attachment #3: Type: text/plain, Size: 77 bytes --]



Guido

--
"Life is like a buffet; it's not good but there's plenty of it."

  reply	other threads:[~2013-05-09 18:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-07  8:40 Problem with Google Calendar Synchronization Guido Van Hoecke
2013-05-07 10:26 ` Tassilo Horn
2013-05-07 13:04   ` Henning Weiss
2013-05-07 20:23     ` Guido Van Hoecke
2013-05-08  8:30       ` Eric S Fraga
2013-05-08 15:45         ` Guido Van Hoecke
2013-05-09  9:54           ` Eric S Fraga
2013-05-09 13:24             ` Guido Van Hoecke
2013-05-09 14:05               ` Eric S Fraga
2013-05-09 18:00                 ` Guido Van Hoecke [this message]
2013-05-09 20:39                   ` Eric S Fraga
2013-05-10  9:04                     ` Guido Van Hoecke
2013-05-10 13:56                       ` Eric S Fraga
2013-05-10 21:39                         ` Guido Van Hoecke
2013-05-11 15:53                           ` Guido Van Hoecke

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=m2d2t0xcc7.fsf@gmail.com \
    --to=guivho@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).