Ejemplo n.º 1
0
 def getDate(carInfo):
     d = IsoDate.from_iso_string('2016-01-01T00:00:00.000+08:00')
     vehicle = carInfo.get("vehicle", None)
     if vehicle is not None:
         vehicleDate = vehicle.get('vehicle_date', None)
         if vehicleDate is not None:
             registrationDate = vehicleDate.get('registration_date', None)
             if registrationDate is not None:
                 d = registrationDate.astimezone(tz.HKT)
     return d
Ejemplo n.º 2
0
 def getDate(shareJob):
     d = IsoDate.from_iso_string('2015-05-09T00:00:00.000+08:00')
     vehicle = shareJob.get("vehicle", None)
     if vehicle is not None:
         vehicleDate = vehicle.get('vehicle_date', None)
         if vehicleDate is not None:
             registrationDate = vehicleDate.get('registration_date', None)
             if registrationDate is not None:
                 # d = IsoDate.from_iso_string(registrationDate)
                 d = registrationDate.astimezone(tz.HKT)
     return d
Ejemplo n.º 3
0
 def get_inspection_date(share_job):
     '''
     :param share_job:
     :return: 年检到期
     '''
     d = IsoDate.from_iso_string('2018-05-09T00:00:00.000+08:00')
     vehicle = share_job.get("vehicle", None)
     if vehicle is not None:
         vehicleDate = vehicle.get('vehicle_date', None)
         if vehicleDate is not None:
             registrationDate = vehicleDate.get('inspection_date', None)
             if registrationDate is not None:
                 d = registrationDate.astimezone(tz.HKT)
     inspection_year = str(d.year)
     inspection_month = str(d.month)
     return inspection_year + '-' + inspection_month
Ejemplo n.º 4
0
 def get_license_date(share_job):
     '''
     :param share_job:
     :return: 初等时间
     '''
     d = IsoDate.from_iso_string('2014-05-09T00:00:00.000+08:00')
     vehicle = share_job.get("vehicle", None)
     if vehicle is not None:
         vehicleDate = vehicle.get('vehicle_date', None)
         if vehicleDate is not None:
             registrationDate = vehicleDate.get('registration_date', None)
             if registrationDate is not None:
                 # d = IsoDate.from_iso_string(registrationDate)
                 d = registrationDate.astimezone(tz.HKT)
     license_year = str(d.year)
     license_month = str(d.month)
     return license_year, license_month
Ejemplo n.º 5
0
 def getDate(shareJob, type):
     typeDict = {
         1: "registration_date",
         2: "inspection_date",
         3: "compulsory_insurance_expire_date"
     }
     d = IsoDate.from_iso_string('2015-05-01T00:00:00.000+08:00')
     vehicle = shareJob.get("vehicle", None)
     if vehicle is not None:
         vehicleDate = vehicle.get('vehicle_date', None)
         if vehicleDate is not None:
             mDate = vehicleDate.get(typeDict[type], None)
             if mDate is not None:
                 d = mDate.astimezone(tz.HKT)
                 if 3 == type:
                     mDate = vehicleDate.get('inspection_date', None)
                     d = mDate.astimezone(tz.HKT)
     return d
Ejemplo n.º 6
0
 def get_compulsory_date(share_job):
     '''
     :param share_job:
     :return: 强险到期
     '''
     d = IsoDate.from_iso_string('2018-05-09T00:00:00.000+08:00')
     # 如果不存在,默认等于年检时间
     vehicle = share_job.get("vehicle", None)
     if vehicle is not None:
         vehicleDate = vehicle.get('vehicle_date', None)
         if vehicleDate is not None:
             registrationDate = vehicleDate.get(
                 'compulsory_insurance_expire_date', None)
             if registrationDate is not None:
                 # d = IsoDate.from_iso_string(registrationDate)
                 d = registrationDate.astimezone(tz.HKT)
     compulsory_year = str(d.year)
     compulsory_month = str(d.month)
     return compulsory_year + '-' + compulsory_month
Ejemplo n.º 7
0
 def getDate(dateType, shareJob):
     d = IsoDate.from_iso_string('2014-06-01T00:00:00.000+08:00')
     vehicle = shareJob.get("vehicle", None)
     if vehicle is not None:
         vehicleDate = vehicle.get('vehicle_date', None)
         if vehicleDate is not None:
             if "registration_date" == dateType:
                 returnDate = vehicleDate.get('registration_date', None)
                 if returnDate is not None:
                     # d = IsoDate.from_iso_string(registrationDate)
                     d = returnDate.astimezone(tz.HKT)
             if "inspection_date" == dateType:
                 returnDate = vehicleDate.get('inspection_date', None)
                 if returnDate is not None:
                     d = returnDate.astimezone(tz.HKT)
                 else:
                     returnDate = vehicleDate.get('registration_date', None)
                     d = returnDate.astimezone(tz.HKT)
     return d
Ejemplo n.º 8
0
Archivo: t.py Proyecto: qinying/test
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import pymongo
import tz
from dt8601 import IsoDate

conn = pymongo.Connection('127.0.0.1', tz_aware=True)
db = conn['kanche']
col = db['share_job']
cur = col.find({})
aa = cur[0]
d = aa['vehicle']['vehicle_date']['registration_date']
print d
print d.astimezone(tz.HKT)
d = IsoDate.from_iso_string('2014-06-01T00:00:00.000+08:00')
print d
print d.astimezone(tz.HKT)