import pytz
from datetime import datetime, date, timedelta
import datetime as dt


def upload_time():
    #! get realtime (server clock)
    now = datetime.now(pytz.timezone('Asia/Yangon'))
    just_now = now.strftime("%Y-%m-%d %H:%M:%S")
    return just_now


def current_day():
    #! get realtime (server clock)
    now = datetime.now(pytz.timezone('Asia/Yangon'))
    just_now = now.strftime("%a")
    return just_now


def get_sundays(year, month):
    # get first day of the month
    d = date(year, month, 1)

    # iterate for each day of the month
    while d.month == month:
        # if sunday, yield date
        if d.weekday() == 6:
            yield d
        # increment date by one day
        d += timedelta(days=1)


def sunday_dates_in_current_month():
    # get current month and next month
    cur_month = date.today().month
    nxt_month = cur_month + 1 if cur_month < 12 else 1

    # get year
    year = date.today().year

    # get list of sundays in current month and next month
    sundays_cur_month = list(get_sundays(year, cur_month))
    sundays_nxt_month = list(get_sundays(year, nxt_month))
    all_sundays = sundays_cur_month + sundays_nxt_month
    return all_sundays
