Пример #1
0
def __geteventdatetime__(request, eventDt, startTime, endTime):
    FROMTIMEZONE = __getTimezone__(request)
    tempst = datetime.strptime(startTime, '%I:%M %p')
    tempst = tempst.strftime('%H:%M')
    tempst = datetime.strptime(tempst, '%H:%M')

    utctime = adjust_datetime_to_timezone(tempst, FROMTIMEZONE, TOTIMEZONE)
    settingtime = adjust_datetime_to_timezone(utctime, TOTIMEZONE,
                                              FROMTIMEZONE)

    if (utctime.year < 1900):
        utctime = utctime + timedelta(1)
        eventDt = eventDt - timedelta(1)
    startTime = utctime.strftime('%H:%M')
    if (utctime.day > 1):
        eventDt = eventDt + timedelta(1)

    tempet = datetime.strptime(endTime, '%I:%M %p')
    tempet = tempet.strftime('%H:%M')
    tempet = datetime.strptime(tempet, '%H:%M')
    utcetime = adjust_datetime_to_timezone(tempet, FROMTIMEZONE, TOTIMEZONE)
    settingtime = adjust_datetime_to_timezone(utcetime, TOTIMEZONE,
                                              FROMTIMEZONE)
    if (utcetime.year < 1900):
        utcetime = utcetime + timedelta(1)
    endTime = utcetime.strftime('%H:%M')
    return eventDt, startTime, endTime
Пример #2
0
def __checkCurrentTime__(request, eventdate, eventtime):
    FROMTIMEZONE = __getTimezone__(request)
    nowutctime = adjust_datetime_to_timezone(CURRENT_DATE, settings.TIME_ZONE,
                                             TOTIMEZONE)
    nowutctime = adjust_datetime_to_timezone(nowutctime, TOTIMEZONE,
                                             FROMTIMEZONE)
    if (nowutctime.year < 1900):
        nowutctime = nowutctime - timedelta(1)
    if (nowutctime.year == 1900 and nowutctime.day > 1):
        nowutctime = nowutctime + timedelta(1)
    timeF = '%I:%M %p'
    starttime = eventtime
    dt = datetime.strptime(starttime, timeF)
    eventdt = datetime.strptime(str(eventdate), "%Y-%m-%d")
    hour = int(dt.strftime('%H'))
    eventdt = eventdt + timedelta(hours=hour)
    eventdt = eventdt + timedelta(minutes=int(dt.strftime('%M')))

    diffmonth = nowutctime.month - eventdt.month
    diffyear = nowutctime.year - eventdt.year
    diffdays = nowutctime.day - eventdt.day
    diffhour = nowutctime.hour - eventdt.hour
    diffminute = nowutctime.minute - eventdt.minute

    if (diffdays >= 0 and diffmonth >= 0 and diffyear >= 0):
        if (diffhour > 0 or (diffhour >= 0 and diffminute > 0)):
            return False
    return True
Пример #3
0
def setUTCTimeZone(request, eventdt, eventTime):
    timeF = '%I:%M %p'
    dt = datetime.datetime.strptime(eventTime, timeF)
    eventdt = eventdt + datetime.timedelta(hours=int(dt.strftime('%H')))
    eventdt = eventdt + datetime.timedelta(minutes=int(dt.strftime('%M')))
    eventdt = adjust_datetime_to_timezone(eventdt, __getTimezone__(request),
                                          'UTC')
    return eventdt