Subversion Repositories SmartDukaan

Rev

Rev 103 | Rev 115 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

'''
Created on 26-Mar-2010

@author: ashish
'''
import datetime
import time
from shop2020.utils import OrderStatus

status_active = 0
status_retired = 1
status_deleted = 2
status_paused = 3
status_added = 4


def to_py_date(java_timestamp):
    seconds = java_timestamp / 1000
    sub_seconds  = (java_timestamp % 1000.0) / 1000.0
    date = datetime.datetime.fromtimestamp(seconds + sub_seconds)
    
    return date

def to_java_date(py_timestamp):
    return int(time.mktime(py_timestamp.timetuple())) * 1000 + py_timestamp.microsecond / 1000

def get_status_fdate_tdate(status, from_date, to_date):
    current_from_date = ""
    current_to_date = ""
    current_status = ""
    
    if status:
        current_status = OrderStatus.get_c_status(status)
    if from_date:
        current_from_date = to_py_date(from_date)   
    if to_date:
        current_to_date = to_py_date(to_date)
    
    return  current_status, current_from_date, current_to_date