Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
103 ashish 1
'''
2
Created on 26-Mar-2010
3
 
4
@author: ashish
5
'''
104 ashish 6
import datetime
7
import time
8
from shop2020.utils import OrderStatus
103 ashish 9
 
10
status_active = 0
11
status_retired = 1
12
status_deleted = 2
13
status_paused = 3
14
status_added = 4
15
 
104 ashish 16
 
17
def to_py_date(java_timestamp):
18
    seconds = java_timestamp / 1000
19
    sub_seconds  = (java_timestamp % 1000.0) / 1000.0
20
    date = datetime.datetime.fromtimestamp(seconds + sub_seconds)
21
 
22
    return date
23
 
24
def to_java_date(py_timestamp):
25
    return int(time.mktime(py_timestamp.timetuple())) * 1000 + py_timestamp.microsecond / 1000
26
 
27
def get_status_fdate_tdate(status, from_date, to_date):
28
    current_from_date = ""
29
    current_to_date = ""
30
    current_status = ""
31
 
32
    if status:
33
        current_status = OrderStatus.get_c_status(status)
34
    if from_date:
35
        current_from_date = to_py_date(from_date)   
36
    if to_date:
37
        current_to_date = to_py_date(to_date)
38
 
39
    return  current_status, current_from_date, current_to_date