[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: If clause depending on name of the day
From: |
PJ Weisberg |
Subject: |
Re: If clause depending on name of the day |
Date: |
Tue, 3 Apr 2012 13:05:00 -0700 |
On Tue, Apr 3, 2012 at 12:32 PM, Lars Ljung <lars@matholka.se> wrote:
> "Sven Bretfeld" <sven.bretfeld@gmx.ch> writes:
>> Is it possible to have an if-condition that looks for the current day?
>> So that the then-expression does something different on Tuesday than on
>> Friday?
>
> (nth 6 (decode-time)) returns 0-6 for Sunday-Saturday.
So you could do something like this:
(require 'cl)
(case (nth 6 (decode-time))
(0
(message "Today is Sunday"))
((1 3 5)
(message "Today is Monday, Wednesday, or Friday"))
(2
(message "Today is Tuesday"))
(t
(message "It's some other day.")))
-PJ
Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.