From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fredrik Unger Subject: Recording Time - org-clock-sum Date: Wed, 05 Nov 2014 18:00:04 +0100 Message-ID: <545A5794.8040203@tree.se> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm4k7-0003qI-Cz for Emacs-orgmode@gnu.org; Wed, 05 Nov 2014 12:51:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm4jy-0001Kv-Da for Emacs-orgmode@gnu.org; Wed, 05 Nov 2014 12:51:39 -0500 Received: from smtp1.biggnet.net ([82.145.128.2]:2563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm4jx-0001Ap-Up for Emacs-orgmode@gnu.org; Wed, 05 Nov 2014 12:51:30 -0500 Received: from tree.se ([82.145.144.65]) by smtp1.biggnet.net (IceWarp 9.4.2) with ESMTP (SSL) id RCF43024 for ; Wed, 05 Nov 2014 18:00:24 +0100 Received: from stgt-5f715674.pool.mediaways.net ([95.113.86.116] helo=[192.168.33.10]) by tree.se with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1Xm3wS-0003Tr-2Z for Emacs-orgmode@gnu.org; Wed, 05 Nov 2014 18:00:24 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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: Emacs-orgmode@gnu.org Hi, I have been using Emacs Orgmode for 3-4 years recording time. It started out with Sacha Chua:s article "Clocking Time with Emacs Org" [1] where the org-dblock-write:rangereport did what I needed. As time went by I have made some adaptations to it and simplified it but kept the core idea [2]. One addition is: that it is not based no increments of 24*60*60 but 1 day, which removed problems by Daylight savings time (in October). Maybe more type safe functions exists like in Perl, [3] but I did not find in org-mode. With my change I rely on that emacs date calculations are in the same shape as [3]. It worked for this case and I stopped at that. I am not a full out user of Orgmode and I do not keep project files. I use one simple file per month to record my work, and it has been a good choice for me. Maybe someday I can switch to some other structure but as the CLOCK lines takes some space, I'd rather "forget" CLOCK history on a monthly basis. Projects do not last more than 2-3 month anyway and the catch-all internal project that is "never ending" would become too crowded with CLOCK lines. It is also easier to spot clocking mistakes if the file is limited to a month. Projects can not be summarized across month, but for my reporting needs that is not needed. The data is clocked as follows [4] per month. More project, items and clocked times are in a normal org file, but this simplified case should do. I want to expand the report to show start/end time + breaks. Eg from : Time report November 2014 <2014-11-05 Wed> -- 8:00 (8.00) to : Time report November 2014 <2014-11-05 Wed> -- 8:00 (8.00) s 07:00 e 16:00 b 11:00-12:00, Format is not set, but I need these time for my reporting. In the normal case it is start-end and lunch. I have tried to work with org-clock-sum to get the data from the CLOCK entries. My elisp is rusty, and I missed that the regexp was */level dependent. I managed to get a list of dates but just from the CLOCK under the Item. (((2014-11-05 12:00) (2014-11-05 14:00)) ((2014-11-05 14:00) (2014-11-05 16:00))) There were some strange duplicates as well so I guess I just did things wrong. To get the wanted result I would need a regexp that scans all CLOCK: and reports the two timestamps and generate a list of ((time1 time2) (time2 time3) (time4 time5) (time5 time6)) filtered on the call with tstart tend like org-clock-sum. For me the actual heading is not needed. With this list I can then flaten it, and if needed sort it : (time1 time2 time2 time3 time4 time5 time5 time6) If I then remove duplicates all together I will get : (time1 time3 time4 time6) where min is start and max is end, and pairs in between are breaks. s time1 e time6 b time3-time4, I did not manage to create this list of all CLOCK values filtered on tstart/tend (which in my case would be one day at the time just like I call org-clock-sum for the total sum). I would be grateful for advice or pointers to a better way to find all CLOCK values. Feel free to publish [2] on the wiki if you find it valuable. If/when I have a full working solution I might publish it on my site. Thank you, Fredrik Unger [1] http://sachachua.com/blog/2007/12/clocking-time-with-emacs-org/ [2] https://tree.se/rangereport.el [3] https://metacpan.org/pod/DateTime#How-DateTime-Math-Works [4] https://tree.se/t.org