[wxPython] how to get day of week?

Hi,

How can I tell from a wxDateTime instance that is a Sunday, Monday, Tueday and so forth? I have tried GetWeekDay() and it returns the error "wxDateTime_GetWeekDay() takes at least 2 arguments (1 given)". According to the manual, it requires 1 optional parameter. If no parameter is given local is assumed. Please help. Thank you.

/lim/

This is because the function is "static", meaning (In Python) that it isn't
a method of some class. This is why the function name is prepended with
"wxDateTime_"--in C++, it is actually "static method" of the wxDateTime
class, so the compiler knows what "self" (what's usually called that anyway,
in Python--the name is arbitrary anyway, being just the first argument in
the method declaration) is. [In C++, this is always (I think) called
"this".]

Anyway, the upshot is that for functions with names like
"wxSomething_Method" in wxPython, you should call them as
    wxSomething_Method(<wxSomething instance>,<the parameters in the C++

).

See the "wxPython notes" section of the documentation.

Chris

···

-------------------------------------------------------------------------
Chris Fama <mailto:Chris.Fama@whollysnakes.com>
         or <mailto:Chris.Fama@uq.net.au>
Brisbane, Australia
Phone: (0/+61)(7) 3870 5639 {10am-10pm GMT+10 on both these numbers please}
Mobile: (0/+61)(400) 833 700
-------------------------------------------------------------------------
Business page: <http://whollysnakes.com>
Personal page: <http://uq.net.au/~zzcfama>
-------------------------------------------------------------------------

----- Original Message -----
From: "TH Lim" <dct_thlim@jhancock.com.my>
To: <wxpython-users@lists.wxwindows.org>
Sent: Tuesday, September 25, 2001 12:18 AM
Subject: [wxPython] how to get day of week?

Hi,

How can I tell from a wxDateTime instance that is a Sunday, Monday, Tueday
and so forth? I have tried GetWeekDay() and it returns the error
"wxDateTime_GetWeekDay() takes at least 2 arguments (1 given)". According
to the manual, it requires 1 optional parameter. If no parameter is given
local is assumed. Please help. Thank you.

/lim/

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

In wxPython API it states that,

wxDateTime::GetWeekDay
WeekDay GetWeekDay(const TimeZone& tz = Local) const
Returns the week day in the given timezone (local one by default).

That doesn't explain how to get the day of the week from an instance of wxDateTime.

Or am I barking at the wrong tree. All I want is to get the day of the week whether it is a Sunday. Monday or Tuesday for a given instance of wxDateTime.

tq.

/lim/

···

At 01:10 PM 25-09-01 +1000, you wrote:

This is because the function is "static", meaning (In Python) that it isn't
a method of some class. This is why the function name is prepended with
"wxDateTime_"--in C++, it is actually "static method" of the wxDateTime
class, so the compiler knows what "self" (what's usually called that anyway,
in Python--the name is arbitrary anyway, being just the first argument in
the method declaration) is. [In C++, this is always (I think) called
"this".]

Anyway, the upshot is that for functions with names like
"wxSomething_Method" in wxPython, you should call them as
    wxSomething_Method(<wxSomething instance>,<the parameters in the C++

).

See the "wxPython notes" section of the documentation.

Chris
-------------------------------------------------------------------------
Chris Fama <mailto:Chris.Fama@whollysnakes.com>
         or <mailto:Chris.Fama@uq.net.au>
Brisbane, Australia
Phone: (0/+61)(7) 3870 5639 {10am-10pm GMT+10 on both these numbers please}
Mobile: (0/+61)(400) 833 700
-------------------------------------------------------------------------
Business page: <http://whollysnakes.com>
Personal page: <http://uq.net.au/~zzcfama>
-------------------------------------------------------------------------

----- Original Message -----
From: "TH Lim" <dct_thlim@jhancock.com.my>
To: <wxpython-users@lists.wxwindows.org>
Sent: Tuesday, September 25, 2001 12:18 AM
Subject: [wxPython] how to get day of week?

> Hi,
>
> How can I tell from a wxDateTime instance that is a Sunday, Monday, Tueday
> and so forth? I have tried GetWeekDay() and it returns the error
> "wxDateTime_GetWeekDay() takes at least 2 arguments (1 given)". According
> to the manual, it requires 1 optional parameter. If no parameter is given
> local is assumed. Please help. Thank you.
>
> /lim/
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@lists.wxwindows.org
> http://lists.wxwindows.org/mailman/listinfo/wxpython-users
>

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

How can I tell from a wxDateTime instance that is a Sunday, Monday, Tueday
and so forth? I have tried GetWeekDay() and it returns the error
"wxDateTime_GetWeekDay() takes at least 2 arguments (1 given)". According
to the manual, it requires 1 optional parameter. If no parameter is given
local is assumed. Please help. Thank you.

It's a bug. There was another method by the same name and so swig chose the
other one. It's now fixed for the next release.

For now you'll have to use Python's time module to do it. You can get the
time_t value from a wxDateTime with the GetTicks method.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

Hi. Are you committed to using the wx routines? If not, here's
something I used to stick in programs just in case I needed it.

···

________________________________________________________________________

from time import * # "Killing time???" said Tick, the WatchDog.

dpm = [31,28,31,30,31,30,31,31,30,31,30,31] # dpm = Days Per Month
mmm = ["","Jan","Feb","Mar","Apr","May","Jun",
         "Jul","Aug","Sep","Oct","Nov","Dec"]
month = ["","January","February","March","April","May","June","July",
         "August","September","October","November","December"]
www = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
week = ["Monday","Tuesday","Wednesday","Thursday",
         "Friday","Saturday","Sunday"]

# NOTE: Month and mmm have a dummy first element of the list. (It's
# either that, or always remember to subtract one from the month
# returned by the OS.) On the other hand, Monday thru Sunday are 0
# through 6, so no need to have a dummy week[0] element.

# (The above three lines might better be thought of as a class "Months"
# with attributes/characteristics/properties dpm,abbr,name) Maybe I'll
# do that someday.

# Get the current time (year, month, day, hour, minute, second,
# weekday, Julian day and Daylight Savings Time (DST) boolean flag) and
# massage it a few times.

today = localtime(time()) # (yyyy,mm,dd,hh,mm,ss,wd,jd,DST)
right_now = strftime("%a %b %d %H:%M:%S %%s %Y",today) % (tzname[today[8]])
created = strftime("%a. %d %b %Y %H:%M:%S %%s",today) % (tzname[today[8]])
yyyy,mm,dd,hh,nn,ss,wd,jd,dst = today
________________________________________________________________________

I freely admit the variable names aren't great, but now you can play
with Month[mm], mmm[mm], week[wd], and www[wd] to your heart's content.

On Tue, 25 Sep 2001, TH Lim wrote:

In wxPython API it states that,

wxDateTime::GetWeekDay
WeekDay GetWeekDay(const TimeZone& tz = Local) const

Returns the week day in the given timezone (local one by default).

That doesn't explain how to get the day of the week from an instance of
wxDateTime.

Or am I barking at the wrong tree. All I want is to get the day of
the week whether it is a Sunday. Monday or Tuesday for a given
instance of wxDateTime.

thanks, but i'm using the standard python function, time, as suggested by one of the wxPython developer.

/lim/

···

At 10:14 AM 25-09-01 -0400, you wrote:

Hi. Are you committed to using the wx routines? If not, here's
something I used to stick in programs just in case I needed it.
________________________________________________________________________

from time import * # "Killing time???" said Tick, the WatchDog.

dpm = [31,28,31,30,31,30,31,31,30,31,30,31] # dpm = Days Per Month
mmm = ["","Jan","Feb","Mar","Apr","May","Jun",
         "Jul","Aug","Sep","Oct","Nov","Dec"]
month = ["","January","February","March","April","May","June","July",
         "August","September","October","November","December"]
www = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
week = ["Monday","Tuesday","Wednesday","Thursday",
         "Friday","Saturday","Sunday"]

# NOTE: Month and mmm have a dummy first element of the list. (It's
# either that, or always remember to subtract one from the month
# returned by the OS.) On the other hand, Monday thru Sunday are 0
# through 6, so no need to have a dummy week[0] element.

# (The above three lines might better be thought of as a class "Months"
# with attributes/characteristics/properties dpm,abbr,name) Maybe I'll
# do that someday.

# Get the current time (year, month, day, hour, minute, second,
# weekday, Julian day and Daylight Savings Time (DST) boolean flag) and
# massage it a few times.

today = localtime(time()) # (yyyy,mm,dd,hh,mm,ss,wd,jd,DST)
right_now = strftime("%a %b %d %H:%M:%S %%s %Y",today) % (tzname[today[8]])
created = strftime("%a. %d %b %Y %H:%M:%S %%s",today) % (tzname[today[8]])
yyyy,mm,dd,hh,nn,ss,wd,jd,dst = today
________________________________________________________________________

I freely admit the variable names aren't great, but now you can play
with Month[mm], mmm[mm], week[wd], and www[wd] to your heart's content.

On Tue, 25 Sep 2001, TH Lim wrote:

> In wxPython API it states that,
>
> wxDateTime::GetWeekDay
> WeekDay GetWeekDay(const TimeZone& tz = Local) const
>
> Returns the week day in the given timezone (local one by default).
>
> That doesn't explain how to get the day of the week from an instance of
> wxDateTime.
>
> Or am I barking at the wrong tree. All I want is to get the day of
> the week whether it is a Sunday. Monday or Tuesday for a given
> instance of wxDateTime.

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users