awips2/edexOsgi/com.raytheon.uf.common.time/utility/common_static/base/python/time/DataTime.py
Nate Jensen c77936c6c0 Issue #2032 move build.edex's common-static files to appropriate plugins
Change-Id: I15fa37459c34dd40b253a97b99d62c5fc8ff4d15

Former-commit-id: 5264d3a5b8 [formerly e2feb9de0c2d7e1d7fb5dac1b0878aabe79f9ab2]
Former-commit-id: b767760a9c
2013-07-18 09:53:53 -05:00

98 lines
No EOL
2.9 KiB
Python

##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
#
# U.S. EXPORT CONTROLLED TECHNICAL DATA
# This software product contains export-restricted data whose
# export/transfer/disclosure is restricted by U.S. law. Dissemination
# to non-U.S. persons whether in the United States or abroad requires
# an export license or other authorization.
#
# Contractor Name: Raytheon Company
# Contractor Address: 6825 Pine Street, Suite 340
# Mail Stop B8
# Omaha, NE 68106
# 402.291.0100
#
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
#
# Python wrapper class that wraps a Java DataTime behind familiar python objects.
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 12/12/12 njensen Initial Creation.
#
#
#
import datetime, time, exceptions
import AbsTime, JUtil, TimeRange
from com.raytheon.uf.common.time import DataTime as JavaDataTime
class DataTime(JUtil.JavaWrapperClass):
def __init__(self, dtime, fcstTime=0):
if isinstance(dtime, AbsTime.AbsTime):
self.__dt = JavaDataTime(dtime.toJavaObj())
elif isinstance(dtime, str):
self.__dt = JavaDataTime(dtime)
else:
# assuming Java object
self.__dt = dtime
# TODO add support for other possible types of dtime?
self.__dt.setFcstTime(fcstTime)
def __eq__(self, other):
return self.__dt.equals(other.toJavaObj())
def __ne__(self, other):
return not self == other
def __lt__(self, other):
return self.__dt.compareTo(other.toJavaObj()) < 0
def __le__(self, other):
return self.__dt.compareTo(other.toJavaObj()) <= 0
def __gt__(self, other):
return self.__dt.compareTo(other.toJavaObj()) > 0
def __ge__(self, other):
return self.__dt.compareTo(other.toJavaObj()) >= 0
def __str__(self):
return str(self.__dt.toString())
def __repr__(self):
return str(self.__dt.toString())
def setFcstTime(self, fcstTime):
self.__dt.setFcstTime(fcstTime)
def getFcstTime(self):
return self.__dt.getFcstTime()
def getValidPeriod(self):
return TimeRange.TimeRange(self.__dt.getValidPeriod())
def setValidPeriod(self, tr):
self.__dt.setValidPeriod(tr.toJavaObj())
def getRefTime(self):
return AbsTime.AbsTime(self.__dt.getRefTime())
def setRefTime(self, refTime):
self.__dt.setRefTime(refTime.toJavaObj())
def toJavaObj(self):
return self.__dt