emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* What is a week?
@ 2023-04-10  3:35 Marcin Borkowski
  2023-04-10  4:03 ` Marcin Borkowski
  2023-04-23 17:57 ` Ihor Radchenko
  0 siblings, 2 replies; 24+ messages in thread
From: Marcin Borkowski @ 2023-04-10  3:35 UTC (permalink / raw)
  To: Org-Mode mailing list

Hi fellow Orgers,

I'm trying to wrap my head around the notion of the week, for the
purpose of using weekly clock tables.

Assume it's Sunday.  I create a clock table with :wstart 0 and
thisweek - and apparently my clock table starts 7 days ago.

Now it's Monday.  I create a clock table with :wstart 1 and thisweek -
and my clock table starts today.

What is the logic behind it?

Help!

-- 
Marcin Borkowski
http://mbork.pl


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10  3:35 What is a week? Marcin Borkowski
@ 2023-04-10  4:03 ` Marcin Borkowski
  2023-04-10  6:04   ` Jude DaShiell
  2023-04-10  7:46   ` Ihor Radchenko
  2023-04-23 17:57 ` Ihor Radchenko
  1 sibling, 2 replies; 24+ messages in thread
From: Marcin Borkowski @ 2023-04-10  4:03 UTC (permalink / raw)
  To: Org-Mode mailing list


On 2023-04-10, at 05:35, Marcin Borkowski <mbork@mbork.pl> wrote:

> Hi fellow Orgers,
>
> I'm trying to wrap my head around the notion of the week, for the
> purpose of using weekly clock tables.
>
> Assume it's Sunday.  I create a clock table with :wstart 0 and
> thisweek - and apparently my clock table starts 7 days ago.
>
> Now it's Monday.  I create a clock table with :wstart 1 and thisweek -
> and my clock table starts today.
>
> What is the logic behind it?

To clarify: I understand that the reason is the `if' from this line from
`org-clock.el':

(setq diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))

(introduced ~10 years ago!).  But why is it coded this way?

Best,

-- 
Marcin Borkowski
http://mbork.pl


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10  4:03 ` Marcin Borkowski
@ 2023-04-10  6:04   ` Jude DaShiell
  2023-04-10  7:46   ` Ihor Radchenko
  1 sibling, 0 replies; 24+ messages in thread
From: Jude DaShiell @ 2023-04-10  6:04 UTC (permalink / raw)
  To: Marcin Borkowski, Org-Mode mailing list

One of the iso standards has weeks starting on Monday.


-- Jude <jdashiel at panix dot com> "There are four boxes to be used in
defense of liberty: soap, ballot, jury, and ammo. Please use in that
order." Ed Howdershelt 1940.

On Mon, 10 Apr 2023, Marcin Borkowski wrote:

>
> On 2023-04-10, at 05:35, Marcin Borkowski <mbork@mbork.pl> wrote:
>
> > Hi fellow Orgers,
> >
> > I'm trying to wrap my head around the notion of the week, for the
> > purpose of using weekly clock tables.
> >
> > Assume it's Sunday.  I create a clock table with :wstart 0 and
> > thisweek - and apparently my clock table starts 7 days ago.
> >
> > Now it's Monday.  I create a clock table with :wstart 1 and thisweek -
> > and my clock table starts today.
> >
> > What is the logic behind it?
>
> To clarify: I understand that the reason is the `if' from this line from
> `org-clock.el':
>
> (setq diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))
>
> (introduced ~10 years ago!).  But why is it coded this way?
>
> Best,
>
>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10  4:03 ` Marcin Borkowski
  2023-04-10  6:04   ` Jude DaShiell
@ 2023-04-10  7:46   ` Ihor Radchenko
  2023-04-10 11:51     ` Max Nikulin
  1 sibling, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2023-04-10  7:46 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-Mode mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

>> Assume it's Sunday.  I create a clock table with :wstart 0 and
>> thisweek - and apparently my clock table starts 7 days ago.
>>
>> Now it's Monday.  I create a clock table with :wstart 1 and thisweek -
>> and my clock table starts today.
>>
>> What is the logic behind it?
>
> To clarify: I understand that the reason is the `if' from this line from
> `org-clock.el':
>
> (setq diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))
>
> (introduced ~10 years ago!).  But why is it coded this way?

The commit goes like

0bca49801eac749b6adf39b176b9455566faac85
Author:     Bastien Guerry <bzg@altern.org>
org-clock.el: Implement a new parameter :wstart to define the week start day

-      (setq diff (+ (* -7 shift) (if (= dow 0) 6 (1- dow)))
+      (setq diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))

I am not sure if there is any particular reason.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10  7:46   ` Ihor Radchenko
@ 2023-04-10 11:51     ` Max Nikulin
  2023-04-10 12:07       ` Tim Landscheidt
  2023-04-11 10:09       ` Ihor Radchenko
  0 siblings, 2 replies; 24+ messages in thread
From: Max Nikulin @ 2023-04-10 11:51 UTC (permalink / raw)
  To: emacs-orgmode

On 10/04/2023 14:46, Ihor Radchenko wrote:
> 0bca49801eac749b6adf39b176b9455566faac85
> Author:     Bastien Guerry
> org-clock.el: Implement a new parameter :wstart to define the week start day
> 
> -      (setq diff (+ (* -7 shift) (if (= dow 0) 6 (1- dow)))
> +      (setq diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))
> 
> I am not sure if there is any particular reason.

https://list.orgmode.org/87y4z481yc.fsf@bzg.ath.cx/
Bastien. Re: Clocktable for this week starting at Sunday. Thu, 17 Apr 
2014 16:28:43 +0200
> Torben Hoffmann writes:
> 
>>     #+BEGIN: clocktable :maxlevel 2 :scope agenda-with-archives
>>      :weekstart 7 :block thisweek :step day :fileskip0 :narrow 20!
>        ^^^^^^^^^^
> 
> should be :wstart -- let us know if it works!

So at least some people expect 7, not 0. I would say, both variants 
should be acceptable.

P.S. It seems, there is no way to get in Emacs first_weekday from locale(5)



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10 11:51     ` Max Nikulin
@ 2023-04-10 12:07       ` Tim Landscheidt
  2023-04-11 10:08         ` Ihor Radchenko
  2023-04-11 10:09       ` Ihor Radchenko
  1 sibling, 1 reply; 24+ messages in thread
From: Tim Landscheidt @ 2023-04-10 12:07 UTC (permalink / raw)
  To: emacs-orgmode

Max Nikulin <manikulin@gmail.com> wrote:

> […]

> So at least some people expect 7, not 0. I would say, both
> variants should be acceptable.

> P.S. It seems, there is no way to get in Emacs first_weekday from locale(5)

But there is calendar-week-start-day which I would expect
affected Emacs users to have customized.

Tim



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10 12:07       ` Tim Landscheidt
@ 2023-04-11 10:08         ` Ihor Radchenko
  2023-04-24 15:47           ` Max Nikulin
  0 siblings, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2023-04-11 10:08 UTC (permalink / raw)
  To: Tim Landscheidt; +Cc: emacs-orgmode

Tim Landscheidt <tim@tim-landscheidt.de> writes:

> But there is calendar-week-start-day which I would expect
> affected Emacs users to have customized.

It is not at all obvious that Org should be affected by calendar
customization. And we use different default - Monday, while
calendar-week-start-days defaults to Sunday.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10 11:51     ` Max Nikulin
  2023-04-10 12:07       ` Tim Landscheidt
@ 2023-04-11 10:09       ` Ihor Radchenko
  2023-04-11 11:34         ` Max Nikulin
  1 sibling, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2023-04-11 10:09 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

>>>     #+BEGIN: clocktable :maxlevel 2 :scope agenda-with-archives
>>>      :weekstart 7 :block thisweek :step day :fileskip0 :narrow 20!
>>        ^^^^^^^^^^
>> 
>> should be :wstart -- let us know if it works!
>
> So at least some people expect 7, not 0. I would say, both variants 
> should be acceptable.

Would you be interested to make a patch?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-11 10:09       ` Ihor Radchenko
@ 2023-04-11 11:34         ` Max Nikulin
  2023-04-11 14:21           ` Marcin Borkowski
  0 siblings, 1 reply; 24+ messages in thread
From: Max Nikulin @ 2023-04-11 11:34 UTC (permalink / raw)
  To: emacs-orgmode

On 11/04/2023 17:09, Ihor Radchenko wrote:
> Max Nikulin writes:
>> So at least some people expect 7, not 0. I would say, both variants
>> should be acceptable.
> 
> Would you be interested to make a patch?

Not really. I expect something like

>        (let* ((ws (mod (or wstart 1) 7))
> 	      (diff (+ (* -7 shift) (- dow ws) (if (> dow ws) 0 7))))

I have realized that current behavior may be considered as a feature. 
Agenda obtained on Sunday allows to review previous working week. So 
:weekstart 0 and :weekstart 7 might behave differently. However to make 
it full-fledged feature, it is necessary to introduce first_workday in 
addition to first_weekday. See properties reported by

      locale -k LC_TIME



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-11 11:34         ` Max Nikulin
@ 2023-04-11 14:21           ` Marcin Borkowski
  0 siblings, 0 replies; 24+ messages in thread
From: Marcin Borkowski @ 2023-04-11 14:21 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode


On 2023-04-11, at 13:34, Max Nikulin <manikulin@gmail.com> wrote:

> On 11/04/2023 17:09, Ihor Radchenko wrote:
>> Max Nikulin writes:
>>> So at least some people expect 7, not 0. I would say, both variants
>>> should be acceptable.
>> Would you be interested to make a patch?
>
> Not really. I expect something like
>
>>        (let* ((ws (mod (or wstart 1) 7))
>> 	      (diff (+ (* -7 shift) (- dow ws) (if (> dow ws) 0 7))))
>
> I have realized that current behavior may be considered as
> a feature. Agenda obtained on Sunday allows to review previous working
> week. So :weekstart 0 and :weekstart 7 might behave
> differently. However to make it full-fledged feature, it is necessary

Actually, my question resulted from me noticing that "last week" behaves
weirdly and the decision to write a blog post about how to display
a clock table for the last week.  In that case, you can always say
`lastweek-1', so I'm not sure if the `0' setting is all that useful.

Best,

-- 
Marcin Borkowski
http://mbork.pl


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-10  3:35 What is a week? Marcin Borkowski
  2023-04-10  4:03 ` Marcin Borkowski
@ 2023-04-23 17:57 ` Ihor Radchenko
  2023-04-23 19:06   ` Marcin Borkowski
  1 sibling, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2023-04-23 17:57 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-Mode mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

> Now it's Monday.  I create a clock table with :wstart 1 and thisweek -
> and my clock table starts today.
>
> What is the logic behind it?

I saw you are considering this as a bug to be fixed.
(https://mbork.pl/2023-04-22_Org_mode_clock_table_for_the_last_week)

But please take a look at Max's email. I do not see changing the current
:wstart 0 behaviour as a no-brainer.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-23 17:57 ` Ihor Radchenko
@ 2023-04-23 19:06   ` Marcin Borkowski
  2023-04-23 19:18     ` Ihor Radchenko
  2023-04-24 15:13     ` Max Nikulin
  0 siblings, 2 replies; 24+ messages in thread
From: Marcin Borkowski @ 2023-04-23 19:06 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org-Mode mailing list


On 2023-04-23, at 19:57, Ihor Radchenko <yantar92@posteo.net> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Now it's Monday.  I create a clock table with :wstart 1 and thisweek -
>> and my clock table starts today.
>>
>> What is the logic behind it?
>
> I saw you are considering this as a bug to be fixed.
> (https://mbork.pl/2023-04-22_Org_mode_clock_table_for_the_last_week)
>
> But please take a look at Max's email. I do not see changing the current
> :wstart 0 behaviour as a no-brainer.

Fair enough.  Still, I consider this a bug in the docs (they don't say
clearly to set :wstart 7)...

Best,

-- 
Marcin Borkowski
http://mbork.pl


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-23 19:06   ` Marcin Borkowski
@ 2023-04-23 19:18     ` Ihor Radchenko
  2023-04-24  4:13       ` Marcin Borkowski
  2023-04-24 15:13     ` Max Nikulin
  1 sibling, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2023-04-23 19:18 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-Mode mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

> Fair enough.  Still, I consider this a bug in the docs (they don't say
> clearly to set :wstart 7)...

Patches welcome!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-23 19:18     ` Ihor Radchenko
@ 2023-04-24  4:13       ` Marcin Borkowski
  2023-04-24  6:26         ` Ihor Radchenko
  0 siblings, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2023-04-24  4:13 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org-Mode mailing list


On 2023-04-23, at 21:18, Ihor Radchenko <yantar92@posteo.net> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Fair enough.  Still, I consider this a bug in the docs (they don't say
>> clearly to set :wstart 7)...
>
> Patches welcome!

Would gladly do.  Has the copyright papers requirement been lifted?

-- 
Marcin Borkowski
http://mbork.pl


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-24  4:13       ` Marcin Borkowski
@ 2023-04-24  6:26         ` Ihor Radchenko
  2023-04-24 19:44           ` Marcin Borkowski
  0 siblings, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2023-04-24  6:26 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-Mode mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

>> Patches welcome!
>
> Would gladly do.  Has the copyright papers requirement been lifted?

Of course not, but don't you already have copyright assignment done?
Our records list you as someone with copyright:
https://orgmode.org/worg/contributors.html

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-23 19:06   ` Marcin Borkowski
  2023-04-23 19:18     ` Ihor Radchenko
@ 2023-04-24 15:13     ` Max Nikulin
  2023-04-24 19:26       ` Marcin Borkowski
  1 sibling, 1 reply; 24+ messages in thread
From: Max Nikulin @ 2023-04-24 15:13 UTC (permalink / raw)
  To: Marcin Borkowski, emacs-orgmode

On 24/04/2023 02:06, Marcin Borkowski wrote:
> 
> Fair enough.  Still, I consider this a bug in the docs (they don't say
> clearly to set :wstart 7)...

I do not think :wstart 7 gives expected result when run on any day other 
than Sunday. Current expression shifts interval start into future, see 
the last column

#+begin_src elisp
(let ((dow-seq (number-sequence 0 6))
       (wstart-seq (number-sequence 0 7))
       (shift 0)
       (diff (lambda (dow ws) ; taken from org-clock.el:
	      (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws))))))
   (cons (cons "dow\\wstart" wstart-seq)
	(mapcar
	 (lambda (dow)
	   (cons dow (mapcar (lambda (ws)
			       (funcall diff dow ws))
			     wstart-seq)))
	 dow-seq)))
#+end_src

#+RESULTS:
| dow\wstart | 0 | 1 |  2 |  3 |  4 |  5 |  6 |  7 |
|          0 | 7 | 6 |  5 |  4 |  3 |  2 |  1 |  0 |
|          1 | 1 | 0 | -1 | -2 | -3 | -4 | -5 | -6 |
|          2 | 2 | 1 |  0 | -1 | -2 | -3 | -4 | -5 |
|          3 | 3 | 2 |  1 |  0 | -1 | -2 | -3 | -4 |
|          4 | 4 | 3 |  2 |  1 |  0 | -1 | -2 | -3 |
|          5 | 5 | 4 |  3 |  2 |  1 |  0 | -1 | -2 |
|          6 | 6 | 5 |  4 |  3 |  2 |  1 |  0 | -1 |

My expectation is values like in column "1" with appropriate cyclic shift.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-11 10:08         ` Ihor Radchenko
@ 2023-04-24 15:47           ` Max Nikulin
  0 siblings, 0 replies; 24+ messages in thread
From: Max Nikulin @ 2023-04-24 15:47 UTC (permalink / raw)
  To: emacs-orgmode

On 11/04/2023 17:08, Ihor Radchenko wrote:
> Tim Landscheidt writes:
> 
>> But there is calendar-week-start-day which I would expect
>> affected Emacs users to have customized.
> 
> It is not at all obvious that Org should be affected by calendar
> customization. And we use different default - Monday, while
> calendar-week-start-days defaults to Sunday.

In general, I agree that Org should respect `calendar-week-start-day'. 
However since different defaults are currently used (US vs. Europe 
conventions), I would wait till support support of calendar properties 
from Unicode Common Locale Data Repository. Users who have not 
customized value should not notice change.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-24 15:13     ` Max Nikulin
@ 2023-04-24 19:26       ` Marcin Borkowski
  0 siblings, 0 replies; 24+ messages in thread
From: Marcin Borkowski @ 2023-04-24 19:26 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode


On 2023-04-24, at 17:13, Max Nikulin <manikulin@gmail.com> wrote:

> On 24/04/2023 02:06, Marcin Borkowski wrote:
>> Fair enough.  Still, I consider this a bug in the docs (they don't
>> say
>> clearly to set :wstart 7)...
>
> I do not think :wstart 7 gives expected result when run on any day
> other than Sunday. Current expression shifts interval start into
> future, see the last column

Ok, so now I am pretty confused...  I thought my experiments showed that
:wstart 7 works every time, now I'm not so sure anymore (especially that
it's very late here...).  I'll look into this tomorrow.

Thanks,

-- 
Marcin Borkowski
http://mbork.pl


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-24  6:26         ` Ihor Radchenko
@ 2023-04-24 19:44           ` Marcin Borkowski
  2023-04-24 20:05             ` Ihor Radchenko
                               ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Marcin Borkowski @ 2023-04-24 19:44 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org-Mode mailing list


On 2023-04-24, at 08:26, Ihor Radchenko <yantar92@posteo.net> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>>> Patches welcome!
>>
>> Would gladly do.  Has the copyright papers requirement been lifted?
>
> Of course not, but don't you already have copyright assignment done?
> Our records list you as someone with copyright:
> https://orgmode.org/worg/contributors.html

Complicated.  I did my copyright assignment (for Emacs and AUCTeX, but
I guess this doesn't matter, since Org mode is part of Emacs anyway)
back when I worked in academia as a mathematician.  Now I am
a professional programmer, so I stopped contributing to Emacs -
I suspect I would need to sign a different form.  Also, my employer
probably should do the same.  And I assume that FSF might want to look
at my contract, which is in Polish, so someone would have to pay for the
translation, too.  Quite a lot of hurdles for relatively little gain.
And don't even mention what I think about that requirement in
particular, and in general about copyright law, American law and
American copyright law...

I certainly don't want to sound like a jerk, but I think I do not owe
anything to Emacs.  While Emacs is an important part of my life - and it
does make my life significantly better - I do my best to give back to
the Emacs community.  I wrote 300+ Emacs-related posts on my blog, more
are in the pipeline, I wrote an Elisp textbook (not free, but that is
intentional - I do not consider GPL nor the "free as in freedom"
approach to be necessarily a good idea for a textbook), I encourage
people to use Emacs (sometimes successfully).

To be clear - I completely understand the "patches welcome" attitude to
people complaining that something doesn't work as they expect -
especially if those people are knowledgeable enough to fix the issue
themselves.  I would very probably have done that several weeks ago if
not for the copyright papers requirement.  If you think this is a good
idea, I may spend some time preparing a detailed bug report, but please
don't count on me submitting patches.

Best,

-- 
Marcin Borkowski
http://mbork.pl


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-24 19:44           ` Marcin Borkowski
@ 2023-04-24 20:05             ` Ihor Radchenko
  2023-08-06 18:29               ` Bastien Guerry
  2023-04-25 14:43             ` [PATCH] org-clock.el: Fix week start != 1 Max Nikulin
  2023-08-06 18:27             ` What is a week? Bastien
  2 siblings, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2023-04-24 20:05 UTC (permalink / raw)
  To: Marcin Borkowski, Bastien; +Cc: Org-Mode mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

> Complicated.  I did my copyright assignment (for Emacs and AUCTeX, but
> ...

Thanks for the clarification.
Bastien, I think we should update the copyright status in WORG. Maybe
also inform FSF?

> To be clear - I completely understand the "patches welcome" attitude to
> people complaining that something doesn't work as they expect -
> especially if those people are knowledgeable enough to fix the issue
> themselves.  I would very probably have done that several weeks ago if
> not for the copyright papers requirement.  If you think this is a good
> idea, I may spend some time preparing a detailed bug report, but please
> don't count on me submitting patches.

Detailed bug report will certainly help. I am a bit lost in what should
be expected here and what is being wrong on Org side.

Also, do note that "patches welcome" is not necessarily aiming at you
specifically. Anyone interested in submitting a patch is welcome.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH] org-clock.el: Fix week start != 1
  2023-04-24 19:44           ` Marcin Borkowski
  2023-04-24 20:05             ` Ihor Radchenko
@ 2023-04-25 14:43             ` Max Nikulin
  2023-05-07  8:06               ` Ihor Radchenko
  2023-08-06 18:27             ` What is a week? Bastien
  2 siblings, 1 reply; 24+ messages in thread
From: Max Nikulin @ 2023-04-25 14:43 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-Mode mailing list

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

On 25/04/2023 02:44, Marcin Borkowski wrote:
> And I assume that FSF might want to look
> at my contract, which is in Polish

I had an impression that an FSF form signed by your employer is enough, 
but I may be wrong.

Could you, please, test if the attached patch works correctly for you?

[-- Attachment #2: 0001-org-clock.el-Fix-week-start-1.patch --]
[-- Type: text/x-patch, Size: 4615 bytes --]

From eb1b0f8e7458a775664dc4dc38d38e14c462fba9 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Tue, 25 Apr 2023 21:25:16 +0700
Subject: [PATCH] org-clock.el: Fix week start != 1

* lisp/org-clock.el (org-clock-special-range): Prevent returning
previous week for `thisweek' KEY when WSTART is 0.  Treat both 0 and 7
as Sunday.
* testing/lisp/test-org-clock.el (test-org-clock/special-range): New
test for `thisweek' and various WSTART arguments.

It seems only the case of weeks starting on Monday was tested.
Other variants caused shifted intervals.

Bug report: Marcin Borkowski. What is a week?
Mon, 10 Apr 2023 05:35:44 +0200.
<https://list.orgmode.org/87h6to1ka7.fsf@mbork.pl>
---
 lisp/org-clock.el              |  2 +-
 testing/lisp/test-org-clock.el | 52 ++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 053050adb..b30018aac 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -2389,7 +2389,7 @@ (defun org-clock-special-range (key &optional time as-strings wstart mstart)
                               d (+ d shift)))
       ((or `week `thisweek)
        (let* ((ws (or wstart 1))
-	      (diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))))
+	      (diff (+ (* -7 shift) (mod (+ dow 7 (- ws)) 7))))
 	 (setq m 0 h org-extend-today-until d (- d diff) d1 (+ 7 d))))
       ((or `month `thismonth)
        (setq h org-extend-today-until m 0 d (or mstart 1)
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index 7d8123e1f..fb16f8ffe 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -1311,5 +1311,57 @@ (ert-deftest test-org-clock/mode-line ()
                      "<after> ")
         (org-clock-out))))))
 
+;;; Helpers
+
+(ert-deftest test-org-clock/special-range ()
+  "Test `org-clock-special-range'."
+  (let* ((cases
+          '((("2023-04-23 Sun" "2023-04-24 Mon" "2023-04-25 Tue" "2023-04-26 Wed"
+              "2023-04-27 Thu" "2023-04-28 Fri" "2023-04-29 Sat")
+             thisweek 0
+             "2023-04-23 Sun" "2023-04-30 Sun")
+            (("2023-04-24 Mon" "2023-04-25 Tue" "2023-04-26 Wed"
+              "2023-04-27 Thu" "2023-04-28 Fri" "2023-04-29 Sat" "2023-04-30 Sun")
+             thisweek 1
+             "2023-04-24 Mon" "2023-05-01 Mon")
+            (("2023-04-24 Mon" "2023-04-25 Tue" "2023-04-26 Wed"
+              "2023-04-27 Thu" "2023-04-28 Fri" "2023-04-29 Sat" "2023-04-30 Sun")
+             thisweek nil ; Copy of 1.
+             "2023-04-24 Mon" "2023-05-01 Mon")
+            (("2023-04-22 Sat"
+              "2023-04-23 Sun" "2023-04-24 Mon" "2023-04-25 Tue" "2023-04-26 Wed"
+              "2023-04-27 Thu" "2023-04-28 Fri")
+             thisweek 6
+             "2023-04-22 Sat" "2023-04-29 Sat")
+            (("2023-04-23 Sun" "2023-04-24 Mon" "2023-04-25 Tue" "2023-04-26 Wed"
+              "2023-04-27 Thu" "2023-04-28 Fri" "2023-04-29 Sat")
+             thisweek 7 ; Copy of 0.
+             "2023-04-23 Sun" "2023-04-30 Sun")))
+         (failed
+          (delq
+           nil
+           (mapcar (lambda (params)
+                     (pcase-let ((`(,days ,key ,wstart ,begin ,end) params))
+                       (delq
+                        nil
+                        (mapcar (lambda (today)
+                                  (let* ((ts-today (org-time-string-to-time today))
+                                         (range (org-clock-special-range
+                                                 key ts-today nil wstart nil))
+                                         (ts-begin (nth 0 range))
+                                         (ts-end (nth 1 range))
+                                         (expected-begin (org-time-string-to-time begin))
+                                         (expected-end (org-time-string-to-time end)))
+                                    (unless (and (equal ts-begin expected-begin)
+                                                 (equal ts-end expected-end))
+                                      (format "%s..%s != %s..%s %s %s :wstart %s"
+                                              begin end
+                                              (format-time-string "%F" ts-begin)
+                                              (format-time-string "%F" ts-end)
+                                              today key wstart))))
+                                days))))
+                   cases))))
+    (should-not failed)))
+
 (provide 'test-org-clock)
 ;;; test-org-clock.el end here
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] org-clock.el: Fix week start != 1
  2023-04-25 14:43             ` [PATCH] org-clock.el: Fix week start != 1 Max Nikulin
@ 2023-05-07  8:06               ` Ihor Radchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Ihor Radchenko @ 2023-05-07  8:06 UTC (permalink / raw)
  To: Max Nikulin; +Cc: Marcin Borkowski, Org-Mode mailing list

Max Nikulin <manikulin@gmail.com> writes:

> Subject: [PATCH] org-clock.el: Fix week start != 1

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ed0cfbd7b

Thanks!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-24 19:44           ` Marcin Borkowski
  2023-04-24 20:05             ` Ihor Radchenko
  2023-04-25 14:43             ` [PATCH] org-clock.el: Fix week start != 1 Max Nikulin
@ 2023-08-06 18:27             ` Bastien
  2 siblings, 0 replies; 24+ messages in thread
From: Bastien @ 2023-08-06 18:27 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Ihor Radchenko, Org-Mode mailing list

Hi Marcin,

I've found your entry in the FSF records for signed contributors but
if you have a new employer, he would have to sign the FSF assignment.

The form is here: https://orgmode.org/request-assign-future.txt

Of course, that's if you *want* to contribute with code and patches.
I do perfectly understand you might not want that, all other forms of
contributions are really appreciated too.

Best,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: What is a week?
  2023-04-24 20:05             ` Ihor Radchenko
@ 2023-08-06 18:29               ` Bastien Guerry
  0 siblings, 0 replies; 24+ messages in thread
From: Bastien Guerry @ 2023-08-06 18:29 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Marcin Borkowski, Org-Mode mailing list

Ihor Radchenko <yantar92@posteo.net> writes:

> Thanks for the clarification.
> Bastien, I think we should update the copyright status in WORG. Maybe
> also inform FSF?

I've updated the status in Worg.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-08-06 18:29 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-10  3:35 What is a week? Marcin Borkowski
2023-04-10  4:03 ` Marcin Borkowski
2023-04-10  6:04   ` Jude DaShiell
2023-04-10  7:46   ` Ihor Radchenko
2023-04-10 11:51     ` Max Nikulin
2023-04-10 12:07       ` Tim Landscheidt
2023-04-11 10:08         ` Ihor Radchenko
2023-04-24 15:47           ` Max Nikulin
2023-04-11 10:09       ` Ihor Radchenko
2023-04-11 11:34         ` Max Nikulin
2023-04-11 14:21           ` Marcin Borkowski
2023-04-23 17:57 ` Ihor Radchenko
2023-04-23 19:06   ` Marcin Borkowski
2023-04-23 19:18     ` Ihor Radchenko
2023-04-24  4:13       ` Marcin Borkowski
2023-04-24  6:26         ` Ihor Radchenko
2023-04-24 19:44           ` Marcin Borkowski
2023-04-24 20:05             ` Ihor Radchenko
2023-08-06 18:29               ` Bastien Guerry
2023-04-25 14:43             ` [PATCH] org-clock.el: Fix week start != 1 Max Nikulin
2023-05-07  8:06               ` Ihor Radchenko
2023-08-06 18:27             ` What is a week? Bastien
2023-04-24 15:13     ` Max Nikulin
2023-04-24 19:26       ` Marcin Borkowski

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).