With python how can I have the start of my weeks start on Wednesday instead of Sunday or Monday?
<p>I am using <code>gmtime, strftime and datetime.</code></p>

<p>To give context I am setting up an on call schedule, and to allow people to easily switch people's on call schedules I wrote a script to change the xml file to accomplish that. To make it a bit easier on everyone on call I set the script up so that you can ask what the week number of a specific date is. Most of the built in functionality uses Sunday or Monday as the starting date, and that is not what I need. </p>

<p>The Function in question:</p>

<p>I know <code>%U</code> starts on Sunday, I just need a work around so that it will calculate for it to start on wednesday.</p>

<pre><code>`#option 2
def getWeek():
    print("\n\n")
    date = input("Enter the date you want the week number of (MM DD YYYY): ")
    if(len(date) != 10):
        print("You typed it in wrong. Try it again.")
        getWeek()
    else:
        d = time.strptime(date, "%m %d %Y")
        print(strftime("%U" + 2, d))`
</code></pre>

<p>Why don't you just manually calculate week # yourself.<br>
Basic algorithm:</p>

<ul>
<li>Get current day of year</li>
<li>Shift back to the nearest Wednesday (or whatever day you want)</li>
<li>Divide by 7 + 1 = Week # (assuming the first partial week is 0)</li>
</ul>

<p>In code:</p>

<pre><code>&gt;&gt;&gt; wednesday = 3    # sunday = 0, monday = 1, etc.
&gt;&gt;&gt; week_no = lambda d: (d.tm_yday - (d.tm_wday-wednesday)%7) // 7 + 1
&gt;&gt;&gt; week_no(time.strptime("10 06 2016", "%m %d %Y")) # Thursday
41
&gt;&gt;&gt; week_no(time.strptime("10 04 2016", "%m %d %Y")) # Tuesday
40
</code></pre>

<p>Sanity Check:</p>

<pre><code>&gt;&gt;&gt; time.strftime("%U", time.strptime("10 06 2016", "%m %d %Y"))
'40'
&gt;&gt;&gt; time.strftime("%U", time.strptime("10 04 2016", "%m %d %Y"))
'40'
</code></pre>

python python-3.x