473,765 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: How to Determine Name of the Day in the Week

Fredrik Lundh wrote:
Henry Chang wrote:
>Instead of getting integers with weekday(), Monday == 0 ... Sunday ==
6; is there a way to get the actual names, such as "Monday ...
Sunday"? I would like to do this without creating a data mapping. :)

if you have a datetime or date object, you can use strftime with the
appropriate formatting code. see the library reference for details.

if you have the weekday number, you can use the calender module:
>import calendar
calendar.day_n ame[0]
'Monday'

(the latter also contains abbreviated day names, month names, and a
bunch of other potentially useful functions and mappings.)

</F>

--
http://mail.python.org/mailman/listinfo/python-list
Hi,

I've tried calendar.month_ name[0], it displays empty string, while
calendar.month_ name[1] is "January"? Why does calendar.month_ name's
index not start with index 0 as calendar.day_na me?

Thanks,
Sophon
Sep 18 '08 #1
3 8283
On Sep 17, 10:20*pm, Keo Sophon <keosop...@gmai l.comwrote:
Fredrik Lundh wrote:
Henry Chang wrote:
Instead of getting integers with weekday(), Monday == 0 ... Sunday==
6; is there a way to get the actual names, such as "Monday ...
Sunday"? I would like to do this without creating a data mapping. :)
if you have a datetime or date object, you can use strftime with the
appropriate formatting code. see the library reference for details.
if you have the weekday number, you can use the calender module:
>>import calendar
>>calendar.day_ name[0]
'Monday'
(the latter also contains abbreviated day names, month names, and a
bunch of other potentially useful functions and mappings.)
</F>
--
http://mail.python.org/mailman/listinfo/python-list

Hi,

I've tried calendar.month_ name[0], it displays empty string, while
calendar.month_ name[1] is "January"? Why does calendar.month_ name's
index not start with index 0 as calendar.day_na me?
Because there's no month 0?

And technically, weeks begin on Sunday, not Monday, but business
likes to think of Monday as day 0 of the week and it doesn't
conflict with any prior date format.
>
Thanks,
Sophon
Sep 18 '08 #2
On Wed, 17 Sep 2008 20:34:02 -0700, Mensanator wrote:
And technically, weeks begin on Sunday, not Monday, but business likes
to think of Monday as day 0 of the week and it doesn't conflict with any
prior date format.
There's no "technicall y" about it. It's an arbitrary starting point, and
consequently there are different traditions to it, even in English.

Besides, I don't think many businesses think of "day 0" at all. Most
people outside of IT start counting from 1, not 0.

In British Commonwealth countries, Sunday is the last day of the week,
not the first, although under American influence that's changing in
Australia at least.

In Poland, the week begins with Monday ("poniedziałek "). Tuesday,
"wtorek", means "second day". Other Slavic countries also start with
Monday.

Similarly, the Lithuanian calendar simple enumerates the days of the
week, starting with Monday, "pirmadieni s" ("first day").

In China, there are at least three different systems of naming the week
days. In two of them, the week starts with Sunday, but in the third
system, Sunday is "zhoumo" ("cycle's end") and Monday is zhouyi ("first
of cycle").

--
Steven
Sep 18 '08 #3
On Sep 18, 12:01*am, Steven D'Aprano
<ste...@REMOVE. THIS.cybersourc e.com.auwrote:
On Wed, 17 Sep 2008 20:34:02 -0700, Mensanator wrote:
And technically, weeks begin on Sunday, not Monday, but business likes
to think of Monday as day 0 of the week and it doesn't conflict with any
prior date format.

There's no "technicall y" about it.
Sure there is, within the tradition I was refering to.
Within that tradition, the start of the week isn't arbitray.

Besides, the documentation specifically says it's using
the European system

<quote>
By default, these calendars have Monday as the first day
of the week, and Sunday as the last (the European convention).
Use setfirstweekday () to set the first day of the week to
Sunday (6) or to any other weekday.
</quote>

So, by default, Python doesn't use the American convention
of weeks starting on Sunday (an American technicality).
This does not contradict what I said.
It's an arbitrary starting point,
Amongst different systems, it's never arbitrary within a system.
and
consequently there are different traditions to it, even in English.
I know, that's why I added the caveat.
>
Besides, I don't think many businesses think of "day 0" at all. Most
people outside of IT start counting from 1, not 0.
The accounting software I use to fill out my timesheet
electronically was obviously created by IT people and
the week begins on Monday. Their will is, of course,
forced on all employees whether they are IT or not.
>
In British Commonwealth countries, Sunday is the last day of the week,
not the first, although under American influence that's changing in
Australia at least.

In Poland, the week begins with Monday ("poniedziałek" ). Tuesday,
"wtorek", means "second day". Other Slavic countries also start with
Monday.

Similarly, the Lithuanian calendar simple enumerates the days of the
week, starting with Monday, "pirmadieni s" ("first day").

In China, there are at least three different systems of naming the week
days. In two of them, the week starts with Sunday, but in the third
system, Sunday is "zhoumo" ("cycle's end") and Monday is zhouyi ("first
of cycle").
Last time I was in Borders, I don't recall seeing any
Polish, Lithuanian or Chinese calendars for sale.
>
--
Steven
Sep 18 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3173
by: Andre | last post by:
Hello all, In my database I have a table with records. (Yes I have!!) Last week a record is changed, but I want to know on which date/time that was. Is there a oracle field in the table (like rownum) in which I can see the time which the recoird has changed?? (please do not answer with the sollution to add an extra "field" in the table and let a trigger fill that field with the changingdate. It
18
2888
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
9
7286
by: PamelaDV | last post by:
I have two problems, actually. I am looking to see if there is a function that will return the day of the week (Monday, Tuesday, Wednesday, etc...) from a date. For instance 2/27/04 is a Friday. Also is there a way to group dates by week? I have a user who wants a report to group by week. I know I could create a table and assign dates to a week, but I'm wondering if anyone has anything out there already done that may be a little bit...
2
8088
by: Guoqi Zheng | last post by:
I know now.dayofweek can return week name, but it is something like, monday, tuesday, I only need to return Mon to represent monday. And for month name, I only need to have jan, Feb, etc. short name but not long name, how can I do this? -- Kind regards Guoqi Zheng guoqi AT meetholland dot com
3
11587
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the content I want to execute based on the name of the asp:Content control. As shown in the code snippet below, to get the content I want to display, I call the GetContentPagePath public method in PageRenderer passing a string duplicating the value...
2
1802
by: cody | last post by:
Hi! we are building an xml-export tool to export our business entities from out app. we use reflection to determine the data type of properties. e.g. we have a class Customer with a CustNo property, and reflection tells us that the type is int. so far so good. Now we have a ContactCollection (which inherits from MyBaseColletion) inside the Customer class.
6
14372
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future, excluding holidays and weekends.' I didn't want to build a table of holidays that would have to be continuously updated, so I searched high and low for a function that would tell me whether a given date was a holiday, to no avail. I did find an...
0
5092
by: mix01 | last post by:
Hi, I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help. Many thanks, Mix01 Version of the program
0
2002
by: pratapmysql | last post by:
Hello All, I am trying to get same day (name) of week of last year in this case date of day is not constraint eg. if december 2007-12-19 day is wednesday ,then last year 2006 wednesday for same is on date 2006-12-20 here day is constarint. i.e. we need to match same day of that week . i have tried a stored procedure to find it, but it doest work as per expectation anyone has query in mysql to find same day of week of last year then help me...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.