diff --git a/src/java/util/__init__.py b/src/java/util/__init__.py index 5b0078e..34753f0 100644 --- a/src/java/util/__init__.py +++ b/src/java/util/__init__.py @@ -10,10 +10,12 @@ __all__ = ["Date", "EventObject", "Locale"] +from datetime import datetime + from java.lang import Object -class Date(Object): +class Date(datetime): """The class Date represents a specific instant in time, with millisecond precision. """ diff --git a/src/system/alarm.py b/src/system/alarm.py index b9738dd..d346a60 100644 --- a/src/system/alarm.py +++ b/src/system/alarm.py @@ -27,6 +27,7 @@ import system.date from java.lang import Object +from java.util import Date class AlarmQueryResults(ABCMeta): @@ -205,10 +206,10 @@ def queryJournal( EventState, Priority, IsSystemEvent. Args: - startDate (datetime): The start of the time range to query. + startDate (Date): The start of the time range to query. Defaults to 8 hours previous to now if omitted. Time range is inclusive. - endDate (datetime): The end of the time range to query. Defaults + endDate (Date): The end of the time range to query. Defaults to "now" if omitted. journalName (str): The journal name to query. priority (list[str]): A list of possible priorities to match. diff --git a/src/system/date.py b/src/system/date.py index be32568..c66816d 100644 --- a/src/system/date.py +++ b/src/system/date.py @@ -55,14 +55,14 @@ from datetime import datetime, timedelta -from java.util import Locale +from java.util import Date, Locale def addDays(date, value): """Add or subtract an amount of days to a given date and time. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -77,7 +77,7 @@ def addHours(date, value): """Add or subtract an amount of hours to a given date and time. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -93,7 +93,7 @@ def addMillis(date, value): time. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -108,7 +108,7 @@ def addMinutes(date, value): """Add or subtract an amount of minutes to a given date and time. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -129,7 +129,7 @@ def addMonths(date, value): available day, in this case April 30th. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -151,7 +151,7 @@ def addSeconds(date, value): """Add or subtract an amount of seconds to a given date and time. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -166,7 +166,7 @@ def addWeeks(date, value): """Add or subtract an amount of weeks to a given date and time. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -181,7 +181,7 @@ def addYears(date, value): """Add or subtract an amount of years to a given date and time. Args: - date (datetime): The starting date. + date (Date): The starting date. value (int): The number of units to add, or subtract if the value is negative. @@ -198,8 +198,8 @@ def daysBetween(date_1, date_2): Daylight Saving Time changes are taken into account. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: int: An integer that is representative of the difference between @@ -217,7 +217,7 @@ def format(date, format="yyyy-MM-dd HH:mm:ss"): directive on strftime(). Args: - date (datetime): The date to format. + date (Date): The date to format. format (str): A format string such as "yyyy-MM-dd HH:mm:ss". Optional. @@ -264,7 +264,7 @@ def getAMorPM(date): after noon. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -295,7 +295,7 @@ def getDayOfMonth(date): month is day 1. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -309,7 +309,7 @@ def getDayOfWeek(date): Sunday is day 1, Saturday is day 7. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -323,7 +323,7 @@ def getDayOfYear(date): year is day 1. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -336,7 +336,7 @@ def getHour12(date): midnight are returned as 0. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -349,7 +349,7 @@ def getHour24(date): is zero. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -361,7 +361,7 @@ def getMillis(date): """Extracts the milliseconds from a date, ranging from 0-999. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -373,7 +373,7 @@ def getMinute(date): """Extracts the minutes from a date, ranging from 0-59. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -385,7 +385,7 @@ def getMonth(date): """Extracts the month from a date, where January is month 0. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -397,7 +397,7 @@ def getQuarter(date): """Extracts the quarter from a date, ranging from 1-4. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -409,7 +409,7 @@ def getSecond(date): """Extracts the seconds from a date, ranging from 0-59. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -431,7 +431,7 @@ def getTimezoneOffset(date=datetime.now()): instant, taking Daylight Saving Time into account. Args: - date (datetime): The instant in time for which to calculate the + date (Date): The instant in time for which to calculate the offset. Uses now() if omitted. Optional. Returns: @@ -455,7 +455,7 @@ def getYear(date): """Extracts the year from a date. Args: - date (datetime): The date to use. + date (Date): The date to use. Returns: int: An integer that is representative of the extracted value. @@ -467,8 +467,8 @@ def hoursBetween(date_1, date_2): """Calculates the number of whole hours between two dates. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: int: An integer that is representative of the difference between @@ -483,8 +483,8 @@ def isAfter(date_1, date_2): """Compares two dates to see if date_1 is after date_2. Args: - date_1 (datetime): The first date. - date_2 (datetime): The second date. + date_1 (Date): The first date. + date_2 (Date): The second date. Returns: bool: True (1) if date_1 is after date_2, False (0) otherwise. @@ -496,8 +496,8 @@ def isBefore(date_1, date_2): """Compares to dates to see if date_1 is before date_2. Args: - date_1 (datetime): The first date. - date_2 (datetime): The second date. + date_1 (Date): The first date. + date_2 (Date): The second date. Returns: bool: True (1) if date_1 is before date_2, False (0) otherwise. @@ -510,9 +510,9 @@ def isBetween(target_date, start_date, end_date): dates. Args: - target_date (datetime): The date to compare. - start_date (datetime): The start of a date range. - end_date (datetime): The end of a date range. This date must be + target_date (Date): The date to compare. + start_date (Date): The start of a date range. + end_date (Date): The end of a date range. This date must be after the start date. Returns: @@ -527,7 +527,7 @@ def isDaylightTime(date=datetime.now()): Time during the date specified. Args: - date (datetime): The date you want to check if the current + date (Date): The date you want to check if the current timezone is observing Daylight Saving Time. Uses now() if omitted. Optional. @@ -558,7 +558,7 @@ def midnight(date): millisecond fields set to zero. Args: - date (datetime): The starting date. + date (Date): The starting date. Returns: datetime: A new date, set to midnight of the day provided. @@ -570,8 +570,8 @@ def millisBetween(date_1, date_2): """Calculates the number of whole milliseconds between two dates. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: long: An integer that is representative of the difference @@ -586,8 +586,8 @@ def minutesBetween(date_1, date_2): """Calculates the number of whole minutes between two dates. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: int: An integer that is representative of the difference between @@ -603,8 +603,8 @@ def monthsBetween(date_1, date_2): Saving Time changes are taken into account. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: int: An integer that is representative of the difference between @@ -659,8 +659,8 @@ def secondsBetween(date_1, date_2): """Calculates the number of whole seconds between two dates. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: int: An integer that is representative of the difference between @@ -676,7 +676,7 @@ def setTime(date, hour, minute, second): set as specified. Args: - date (datetime): The starting date. + date (Date): The starting date. hour (int): The hours (0-23) to set. minute(int): The minutes (0-59) to set. second (int): The seconds (0-59) to set. @@ -692,7 +692,7 @@ def toMillis(date): January 1, 1970, 00:00:00 UTC (GMT). Args: - date (datetime): The date object to convert. + date (Date): The date object to convert. Returns: int: 8-byte integer representing the number of millisecond @@ -708,8 +708,8 @@ def weeksBetween(date_1, date_2): """Calculates the number of whole weeks between two dates. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: int: An integer that is representative of the difference between @@ -724,8 +724,8 @@ def yearsBetween(date_1, date_2): Saving Time changes are taken into account. Args: - date_1 (datetime): The first date to use. - date_2 (datetime): The second date to use. + date_1 (Date): The first date to use. + date_2 (Date): The second date to use. Returns: int: An integer that is representative of the difference between diff --git a/src/system/eam.py b/src/system/eam.py index a5cf154..3dfbb7c 100644 --- a/src/system/eam.py +++ b/src/system/eam.py @@ -14,7 +14,7 @@ import system.date from java.lang import Object -from java.util import Locale +from java.util import Date, Locale from system.dataset import Dataset @@ -71,9 +71,9 @@ def queryAgentHistory( agentIds (list[str]): A list of agent names to restrict the results to. If not specified, all agents will be allowed. Optional. - startDate (datetime): The starting time for history events. If + startDate (Date): The starting time for history events. If null, defaults to 8 hours previous to now. Optional. - endDate (datetime): The ending time for the query range. If + endDate (Date): The ending time for the query range. If null, defaults to "now". Optional. limit (int): The limit of results to return. Defaults to 100. A value of 0 means "no limit". Optional. diff --git a/src/system/opchda.py b/src/system/opchda.py index d69955f..05fdb9c 100644 --- a/src/system/opchda.py +++ b/src/system/opchda.py @@ -27,6 +27,7 @@ from abc import ABCMeta, abstractmethod from java.lang import Object +from java.util import Date class Aggregate(ABCMeta): @@ -237,8 +238,8 @@ def readAttributes(serverName, itemId, attributeIds, startDate, endDate): specification. The attributes can also be obtained by calling system.opchda.getAttributes(). Some servers may not support all attributes. - startDate (datetime): The starting date/time of the query. - endDate (datetime): The ending date/time of the query. + startDate (Date): The starting date/time of the query. + endDate (Date): The ending date/time of the query. Returns: list[ReadResult]: A list of read results which is one-to-one @@ -264,8 +265,8 @@ def readProcessed( serverName (str): The name of the defined OPC-HDA server to read. itemIds (list[str]): A list of item ids to read. - startDate (datetime): The starting date/time of the query. - endDate (datetime): The ending date/time of the query. + startDate (Date): The starting date/time of the query. + endDate (Date): The ending date/time of the query. resampleIntervalMS (int): The interval, in milliseconds, that each value should cover. aggregates (list[object]): A list which should be one-to-one @@ -302,8 +303,8 @@ def readRaw( serverName (str): The name of the defined OPC-HDA server to read. itemIds (list[str]): A list of item ids to read. - startDate (datetime): The starting date/time of the query. - endDate (datetime): The ending date/time of the query. + startDate (Date): The starting date/time of the query. + endDate (Date): The ending date/time of the query. maxValues (int): The maximum number of values to return. 0 or less means unlimited. boundingValues (bool): A boolean indicating whether or not the @@ -330,7 +331,7 @@ def replace(serverName, itemId, value, date, quality): serverName (str): The name of the defined OPC-HDA server. itemId (str): The item ID to perform the operation on. value (object): The value to replace. - date (datetime): The date to replace. + date (Date): The date to replace. quality (int): The quality to replace. Returns: diff --git a/src/system/tag.py b/src/system/tag.py index 67e7fe5..b03c46b 100644 --- a/src/system/tag.py +++ b/src/system/tag.py @@ -47,6 +47,7 @@ import system.date from java.lang import Object +from java.util import Date class BrowseTag(Object): @@ -702,10 +703,10 @@ def queryTagCalculations( "SimpleAverage", "Sum", "Minimum", "Maximum", "DurationOn", "DurationOff", "CountOn", "CountOff", "Count", "Range", "Variance", "StdDev", "PctGood", and "PctBad". - startDate (datetime): The starting point for the calculation + startDate (Date): The starting point for the calculation window. If omitted, and range is not used, 8 hours before the current time is used. Optional. - endDate (datetime): The end of the calculation window. If + endDate (Date): The end of the calculation window. If omitted, and range is not used, uses the current time. Optional. rangeHours (int): Allows you to specify the query range in @@ -777,8 +778,8 @@ def queryTagDensity(paths, startDate, endDate): Args: paths (list[str]): An array of Tag paths (strings) to query. - startDate (datetime): The start of the range to query. - endDate (datetime): The end of the range to query. + startDate (Date): The start of the range to query. + endDate (Date): The end of the range to query. Returns: Dataset: A 2-column dataset consisting of a timestamp and a @@ -820,9 +821,9 @@ def queryTagHistory( paths (list[str]): An array of tag paths (strings) to query. Each tag path specified will be a column in the result dataset. - startDate (datetime): The earliest value to retrieve. If + startDate (Date): The earliest value to retrieve. If omitted, 8 hours before current time is used. Optional. - endDate (datetime): The latest value to retrieve. If omitted, + endDate (Date): The latest value to retrieve. If omitted, current time is used. Optional. returnSize (int): The number of samples to return. -1 will return values as they changed, and 0 will return the diff --git a/src/system/user.py b/src/system/user.py index 072b08a..2c12929 100644 --- a/src/system/user.py +++ b/src/system/user.py @@ -44,7 +44,7 @@ import system.date from java.lang import Object -from java.util import Locale +from java.util import Date, Locale class ContactInfo(Object): @@ -61,7 +61,7 @@ def __init__(self, name, date, repeatAnnually): Args: name (str): The name. - date (datetime): The date. + date (Date): The date. repeatAnnually (bool): Repeat annually. """ self.name = name @@ -223,9 +223,9 @@ def addScheduleAdjustment(cls, start, end, available=True, note=None): adjustment easily. Args: - start (datetime): Date to start the schedule adjustment. Not + start (Date): Date to start the schedule adjustment. Not null. - end (datetime): Date to end start the schedule adjustment. + end (Date): Date to end start the schedule adjustment. Not null. available (bool): True if the employee is available during this period. Optional. @@ -470,9 +470,9 @@ def createScheduleAdjustment(startDate, endDate, isAvailable, note): """Creates a schedule adjustment. Args: - startDate (datetime): The starting date of the schedule + startDate (Date): The starting date of the schedule adjustment. - endDate (datetime): The ending date of the schedule adjustment. + endDate (Date): The ending date of the schedule adjustment. isAvailable (bool): True if the user is available during this schedule adjustment. note (str): A note about the schedule adjustment. diff --git a/src/system/util.py b/src/system/util.py index 5fd8596..866952e 100644 --- a/src/system/util.py +++ b/src/system/util.py @@ -56,6 +56,7 @@ import system.date import system.security from java.lang import Object, Thread +from java.util import Date from system.dataset import Dataset, PyDataSet @@ -299,7 +300,7 @@ def audit( be populated automatically if omitted. originatingSystem (object): An even-length list providing additional context to the audit event. Optional. - eventTimestamp (datetime): When the event happened. Will be set + eventTimestamp (Date): When the event happened. Will be set to the current time if omitted. Optional. originatingContext (int): What scope the event originated from: 1 means Gateway, 2 means Designer, 4 means Client. Will be @@ -813,9 +814,9 @@ def queryAuditLog( Args: auditProfileName (str): The name of the audit profile to pull the history from. - startDate (datetime): The earliest audit event to return. If + startDate (Date): The earliest audit event to return. If omitted, the current time - 8 hours will be used. Optional. - endDate (datetime): The latest audit event to return. If + endDate (Date): The latest audit event to return. If omitted, the current time will be used. Optional. actorFilter (str): A filter string used to restrict the results by actor. Optional.