comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: days of the week
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: days of the week [message #29868 is a reply to message #29866] Wed, 20 March 2002 07:47 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Bastienne Schneiter (b.schneiter@meteonews.ch) writes:

> I need to show a date in a little application. Its format is
> YYYYMMDDHH. But I also have to show to which day of the week this date
> correspond (MON, TUE etc).
> Does anybody know how to determine the day of the week for a given
> date?

Alright. Here is a little function that, given the
julian date, will tell you what day of the week it
is. For example, suppose you want to get married
on November 17, 2002 and the preacher asks you what
day of the week that is. You do this:

"Uh, hold-on...."

IDL> juliandate = Julday(11, 17, 2002)
IDL> Print, WhatDayIsIt(juliandate)
Sunday

"Uh, that's a Sunday, Man."

Cheers,

David

P.S. Sorry for the FOR loop. I was in a hurry. :-(

************************************************************ ************
FUNCTION WhatDayIsIt, juliandate

; Need a date? Duh...

IF N_Elements(juliandate) EQ 0 THEN $
juliandate = Systime(/Julian)

; Make a table. Use week of March 17th, 2002.

daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', $
'Thursday', 'Friday', 'Saturday']
datemod = IntArr(7)

FOR j=0,6 DO BEGIN
jdate = Julday(3, 17 + j, 2002)
datemod[j] = jdate MOD 7
ENDFOR

; Convert to day, month, year.

CalDat, juliandate, month, day, year
jdate = Julday(month, day, year)

; What day of the week is it? Return it.

index = Where(datemod EQ (jdate MOD 7))
RETURN, daysOfWeek[index]
END
************************************************************ ************

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: A little handy date function
Next Topic: Re: IDL Movie Viewer

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:51:46 PDT 2025

Total time taken to generate the page: 0.00416 seconds