Get current month

Discussion of Common Lisp
Post Reply
Stiv
Posts: 11
Joined: Wed Sep 29, 2010 6:52 am

Get current month

Post by Stiv » Tue Dec 28, 2010 2:51 am

Hi all,

Sorry but I can't get current month :(.
How can I do it?

Thanks,
bye

Duke
Posts: 38
Joined: Sat Oct 17, 2009 10:40 pm
Contact:

Re: Get current month

Post by Duke » Tue Dec 28, 2010 3:30 am

Stiv wrote:Hi all,

Sorry but I can't get current month :(.
How can I do it?

Thanks,
bye
I'm thinking you're going to want at least two of these functions:

Code: Select all

multiple-value-bind
decode-universal-time
get-universal-time
Look them up if you don't know what they are.
"If you want to improve, be content to be thought foolish and stupid." -Epictetus

Stiv
Posts: 11
Joined: Wed Sep 29, 2010 6:52 am

Re: Get current month

Post by Stiv » Tue Dec 28, 2010 5:24 am

Thanks very much,

I've done so:

Code: Select all

(multiple-value-bind (s min b gg m a b2 b3 b4) 
     (decode-universal-time (get-universal-time))
   (list m))
but it generates many style-warning, how can I improve it?

Thanks,

Bye

gugamilare
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil
Contact:

Re: Get current month

Post by gugamilare » Tue Dec 28, 2010 7:02 am

Try this:

Code: Select all

(multiple-value-bind (s min b gg m a b2 b3 b4) 
     (decode-universal-time (get-universal-time))
   (declare (ignore s min b gg a b2 b3 b4))
   (list m))

Stiv
Posts: 11
Joined: Wed Sep 29, 2010 6:52 am

Re: Get current month

Post by Stiv » Tue Dec 28, 2010 7:45 am

Thanks, it works.

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: Get current month

Post by nuntius » Tue Dec 28, 2010 7:00 pm

A 1-liner:

Code: Select all

(fifth (multiple-value-list (decode-universal-time (get-universal-time))))

Warren Wilkinson
Posts: 117
Joined: Tue Aug 10, 2010 11:24 pm
Location: Calgary, Alberta
Contact:

Re: Get current month

Post by Warren Wilkinson » Tue Dec 28, 2010 8:19 pm

Another 1-liner =)

Code: Select all

(nth-value 4 (decode-universal-time (get-universal-time)))
Need an online wiki database? My Lisp startup http://www.formlis.com combines a wiki with forms and reports.

Stiv
Posts: 11
Joined: Wed Sep 29, 2010 6:52 am

Re: Get current month

Post by Stiv » Wed Dec 29, 2010 3:38 am

Thanks very much :)

Post Reply