Subversion Repositories SmartDukaan

Rev

Rev 103 | Rev 115 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 103 Rev 104
Line 1... Line 1...
1
'''
1
'''
2
Created on 26-Mar-2010
2
Created on 26-Mar-2010
3
 
3
 
4
@author: ashish
4
@author: ashish
5
'''
5
'''
-
 
6
import datetime
-
 
7
import time
-
 
8
from shop2020.utils import OrderStatus
6
 
9
 
7
status_active = 0
10
status_active = 0
8
status_retired = 1
11
status_retired = 1
9
status_deleted = 2
12
status_deleted = 2
10
status_paused = 3
13
status_paused = 3
11
status_added = 4
14
status_added = 4
12
 
15
 
-
 
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