source: TI02-CSML/trunk/parser/API/ops_AbstractFeature.py @ 1410

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/parser/API/ops_AbstractFeature.py@1410
Revision 1410, 989 bytes checked in by domlowe, 13 years ago (diff)

Random non-internet times cannot be converted to CDtimes so added exception to return original time to getCDtime method

Line 
1''' ops_AbstractFeature  contains operations for AbstractFeatures'''
2from API import *
3import cdtime
4
5def testmethod(self):
6    print 'testmethod for abstract feature'
7    return 'testmethod abstract feature'
8
9def getAllowedSubsettings(self):
10    return ['none']
11
12def __compareTimes(timemin, timecheck, timemax):
13
14    year=int(timecheck.split('-')[0])
15    month=int(timecheck.split('-')[1])
16    day=int(timecheck.split('-')[2].split('T')[0])
17    tcheck=cdtime.comptime(year,month,day)
18    timeok=0
19    if tcheck.cmp(timemin) >= 0:
20        if tcheck.cmp(timemax) < 1:
21            print tcheck
22            timeok = 1
23    return timeok
24
25def __getCDtime(time):
26    try:
27        year=int(time.split('-')[0])
28        month=int(time.split('-')[1])
29        day=int(time.split('-')[2].split('T')[0])
30        cdTimeVal=cdtime.comptime(year,month,day)
31    except:
32        #if it's not a proper internet time e.g. time = '6' then return the original time back.
33        return time
34    return cdTimeVal
Note: See TracBrowser for help on using the repository browser.