Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import time
- import calendar
- from sys import *
- cur_date = time.localtime()#time.strptime("25 Sep 13", "%d %b %y")
- week_days = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"]
- months_names = ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"]
- #week_days = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]
- month_weekdays = [0] * (calendar.mdays[cur_date.tm_mon])
- # To past
- cur_day = cur_date.tm_mday
- cur_weekday = cur_date.tm_wday
- while cur_day != 0:
- if cur_weekday < 0:
- cur_weekday = 6
- month_weekdays[cur_day - 1] = cur_weekday
- cur_day -= 1
- cur_weekday -= 1
- # To future
- cur_day = cur_date.tm_mday
- cur_weekday = cur_date.tm_wday
- while cur_day <= len(month_weekdays):
- if cur_weekday > 6:
- cur_weekday = 0
- month_weekdays[cur_day - 1] = cur_weekday
- cur_day += 1
- cur_weekday += 1
- # Print output
- # 28 - 4 = 24 - len
- months_names[cur_date.tm_mon - 1]
- stdout.write("\033[0;31m+")
- stdout.write("\033[0;36m-" * 2)
- stdout.write("\033[0;33m %s " % months_names[cur_date.tm_mon - 1])
- stdout.write("\033[0;36m-" * (24 - (months_names[cur_date.tm_mon - 1].__len__() / 2)))
- stdout.write("\033[0;31m+\n\033[0;36m|")
- for wday in week_days:
- stdout.write(" \033[0m%s " % wday)
- stdout.write("\033[0;36m|\n")
- stdout.write("\033[0;31m+")
- stdout.write("\033[0;36m-" * 28)
- stdout.write("\033[0;31m+\n")
- for date in range(len(month_weekdays)):
- if date == 0:
- stdout.write("\033[0;36m|")
- stdout.write(" " * (4 * month_weekdays[date]))
- if (date + 1) == cur_date.tm_mday:
- stdout.write("\033[1;32m %02d \033[0m" % (date + 1))
- else:
- stdout.write("\033[0m %02d " % (date + 1))
- if date == len(month_weekdays) - 1 and month_weekdays[date] != 6:
- stdout.write(" " * (4 * (6 - month_weekdays[date])))
- stdout.write("\033[0;36m|")
- if month_weekdays[date] == 6:
- if date == len(month_weekdays) - 1:
- stdout.write("\033[0;36m|")
- else:
- stdout.write("\033[0;36m|\n|")
- stdout.write("\n\033[0;31m+")
- stdout.write("\033[0;36m-" * 28)
- stdout.write("\033[0;31m+\n\033[0m")
Advertisement
Add Comment
Please, Sign In to add comment