[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: If clause depending on name of the day
From: |
Pascal J. Bourguignon |
Subject: |
Re: If clause depending on name of the day |
Date: |
Tue, 03 Apr 2012 23:03:34 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) |
PJ Weisberg <pj@irregularexpressions.net> writes:
> 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.")))
(message "Today is %s" (aref ["Sunday" "Monday" "Tuesday" "Wednesday"
"Thirsday" "Friday" "Saturday"]
(nth 6 (decode-time))))
--> "Today is Tuesday"
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.