emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Convert from date to week number, howto?
@ 2012-02-02 16:16 François Pinard
  2012-02-02 16:32 ` Nick Dokos
  2012-02-02 17:02 ` Jambunathan K
  0 siblings, 2 replies; 5+ messages in thread
From: François Pinard @ 2012-02-02 16:16 UTC (permalink / raw)
  To: emacs-orgmode

Hi, Orger friends :-)

I sometimes have to convert from a date to a week number, for when I am
shift-arrowing a clock table summarizing weeks.  It was easy at the
beginning of the year, but I see it requires more thought as year
advance.  I can write little programs to do so, but I wonder if someone
has an easy trick in Org mode (or in Emacs)?

If none, maybe that C-!, or something related to dates or calendar
display, could show the week number for each week?  (random ideas! ...)

François

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

* Re: Convert from date to week number, howto?
  2012-02-02 16:16 Convert from date to week number, howto? François Pinard
@ 2012-02-02 16:32 ` Nick Dokos
  2012-02-12  5:17   ` François Pinard
  2012-02-02 17:02 ` Jambunathan K
  1 sibling, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2012-02-02 16:32 UTC (permalink / raw)
  To: =?utf-8?Q?Fran=C3=A7ois?= Pinard; +Cc: nicholas.dokos, emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> wrote:

> Hi, Orger friends :-)
> 
> I sometimes have to convert from a date to a week number, for when I am
> shift-arrowing a clock table summarizing weeks.  It was easy at the
> beginning of the year, but I see it requires more thought as year
> advance.  I can write little programs to do so, but I wonder if someone
> has an easy trick in Org mode (or in Emacs)?
> 

The agenda shows it in the daily/weekly view, so you can go to the date
of interest and do a day view: vd. Or you can crib the code that
calculates it and incorporate it into your own function
(org-days-to-iso-week does it but it requires a day number since BCE I
think, so you have to do some figuring).

Nick

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

* Re: Convert from date to week number, howto?
  2012-02-02 16:16 Convert from date to week number, howto? François Pinard
  2012-02-02 16:32 ` Nick Dokos
@ 2012-02-02 17:02 ` Jambunathan K
  2012-02-03 15:58   ` Georges Ko
  1 sibling, 1 reply; 5+ messages in thread
From: Jambunathan K @ 2012-02-02 17:02 UTC (permalink / raw)
  To: François Pinard; +Cc: emacs-orgmode


> I sometimes have to convert from a date to a week number, 

Try this. 

(org-odt-format-date "<2011-12-31 Sat>" "%U")
(org-odt-format-date "[2011-12-24 Sat]" "%U")

You can steal the implementation. The functions have nothing to do with
org-odt, btw.

-- 

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

* Re: Convert from date to week number, howto?
  2012-02-02 17:02 ` Jambunathan K
@ 2012-02-03 15:58   ` Georges Ko
  0 siblings, 0 replies; 5+ messages in thread
From: Georges Ko @ 2012-02-03 15:58 UTC (permalink / raw)
  To: emacs-orgmode

Jambunathan K <kjambunathan@gmail.com> writes:

>> I sometimes have to convert from a date to a week number, 
>
> Try this. 
>
> (org-odt-format-date "<2011-12-31 Sat>" "%U")
> (org-odt-format-date "[2011-12-24 Sat]" "%U")
>
> You can steal the implementation. The functions have nothing to do with
> org-odt, btw.

Another way to get the week of the year is:

(require 'calendar)
(require 'cal-iso)

(car
  (calendar-iso-from-absolute
    (calendar-absolute-from-gregorian 
      (list month day year))))
-- 
 Georges Ko                     gko@gko.net                      2012-02-03

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

* Re: Convert from date to week number, howto?
  2012-02-02 16:32 ` Nick Dokos
@ 2012-02-12  5:17   ` François Pinard
  0 siblings, 0 replies; 5+ messages in thread
From: François Pinard @ 2012-02-12  5:17 UTC (permalink / raw)
  To: emacs-orgmode

> François Pinard <pinard@iro.umontreal.ca> wrote:
>> I sometimes have to convert from a date to a week number

Nick Dokos <nicholas.dokos@hp.com> writes:
> org-days-to-iso-week

Jambunathan K <kjambunathan@gmail.com> writes:
> (org-odt-format-date "<2011-12-31 Sat>" "%U")
> (org-odt-format-date "[2011-12-24 Sat]" "%U")

Georges Ko <gko@gko.net> writes:
> (require 'calendar)
> (require 'cal-iso)
> (car
>   (calendar-iso-from-absolute
>     (calendar-absolute-from-gregorian 
>       (list month day year))))

Thanks for these solutions!

François

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

end of thread, other threads:[~2012-02-12  5:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-02 16:16 Convert from date to week number, howto? François Pinard
2012-02-02 16:32 ` Nick Dokos
2012-02-12  5:17   ` François Pinard
2012-02-02 17:02 ` Jambunathan K
2012-02-03 15:58   ` Georges Ko

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