Пример #1
0
 def get_landing_time():
     loading_list = [
         self.flightDate.strftime('%Y-%m-%d'),
         self.landingTime.strftime('%H:%M:%S')
     ]
     return date_converter.string_to_timestamp(' '.join(loading_list),
                                               '%Y-%m-%d %H:%M:%S')
Пример #2
0
        def get_departure_time():

            departure_list = [
                self.flightDate.strftime('%Y-%m-%d'),
                self.departureTime.strftime('%H:%M:%S')
            ]
            return date_converter.string_to_timestamp(' '.join(departure_list),
                                                      '%Y-%m-%d %H:%M:%S')
Пример #3
0
def convert_from_string(string, current_format, to_format, to_type=str):
    if to_type == str:
        return converter.string_to_string(string, current_format, to_format)
    elif to_type == datetime:
        return converter.string_to_datetime(string, current_format, to_format)
    elif to_type == date:
        return converter.string_to_date(string, current_format)
    elif to_type == float:
        return converter.string_to_timestamp(string, current_format)
Пример #4
0
def convert_from_string(string, current_format, to_format, to_type=str):
    if to_type == str:
        return converter.string_to_string(string, current_format, to_format)
    elif to_type == datetime:
        return converter.string_to_datetime(string, current_format, to_format)
    elif to_type == date:
        return converter.string_to_date(string, current_format)
    elif to_type == float:
        return converter.string_to_timestamp(string, current_format)
Пример #5
0
    def wrapper(self, *args, **kwargs):
        start = request.args.get('start')
        end = request.args.get('end')

        if not start or not end:
            return jsonify(code=400, message='请求的时间区间不正确'), 400

        start_obj = date_converter.string_to_date(start, timestamp_format)
        end_obj = date_converter.string_to_date(end, timestamp_format)

        # 超过了当天时间
        events = []
        if start_obj > date.today():
            return jsonify(events)

        if end_obj < date.today() or (date.today().day == 1 and start_obj.month != date.today().month):
            # 区间[start, end), end通常为下个月的1号
            total_day = (end_obj - start_obj).days
        else:
            # 需要含当天
            total_day = (date.today() - start_obj).days + 1

        for idx in range(total_day):
            str_fmt = start_obj.replace(
                day=start_obj.day + idx).strftime(timestamp_format)
            timestamp = date_converter.string_to_timestamp(
                str_fmt, timestamp_format)
            ret = f(self, str_fmt, timestamp)
            if ret is None:
                continue

            url, title, className = ret

            events.append(
                dict(title=title, start=str_fmt, url=url, className=className))

        return jsonify(events)
Пример #6
0
    time_rn = time.time()
    time_in_three_months = 2629743.83 * 3
    for row in table.findAll('tr'):
        if not skipped:
            skipped = True
            continue

        user_id = row.find('a', {'class': 'user-link'}).get('data-id')
        last_seen = row.find('a', {'data-tip': 'bottom'}).get('href')[33:]

        if time_rn - int(last_seen) < time_in_three_months:

            day = date_converter.timestamp_to_string(int(last_seen),
                                                     "%d/%m/%Y")
            last_seen = int(date_converter.string_to_timestamp(
                day, "%d/%m/%Y")) + 7200

            history[last_seen] = user_id

    properties['history'] = history
    data[original_id] = properties
    print ""

f = open(output, 'a')

for item in data:

    for history in data[item]['history']:
        begin_date = date_converter.timestamp_to_string(int(history), "%m/%d")
        end_date = date_converter.timestamp_to_string(
            int(history) - 86400, "%m/%d")