Skip to content

Instantly share code, notes, and snippets.

@gitzxon
Last active July 30, 2018 07:16
Show Gist options
  • Save gitzxon/ecc567b0029219d9706a26f72f32bb46 to your computer and use it in GitHub Desktop.
Save gitzxon/ecc567b0029219d9706a26f72f32bb46 to your computer and use it in GitHub Desktop.
周报.py
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import datetime
date1 = datetime.datetime.now()
this_week_monday = date1 - datetime.timedelta(days=date1.weekday())
this_week_friday = date1 + datetime.timedelta(days=6-date1.weekday())
# print this_week_monday, this_week_friday
this_week_monday_str = str(this_week_monday).split()[0]
this_week_friday_str = str(this_week_friday).split()[0]
# print this_week_monday_str, this_week_friday_str
#上个星期一和星期天的日期
last_week_monday = this_week_monday - datetime.timedelta(days=7)
last_week_friday = this_week_friday - datetime.timedelta(days=7)
last_week_monday_str = str(last_week_monday).split()[0]
last_week_friday_str = str(last_week_friday).split()[0]
# print last_week_monday_str, last_week_friday_str
def print_date(is_monday):
if is_monday:
target = last_week_monday
else:
target = last_week_friday
print str(target).split()[0].replace('-', '')
print_date(is_monday=True)
print_date(is_monday=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment