예제 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="val">Value for this type</param>
 public ONTime(ONTime val)
 {
     if (val == null)
         Value = null;
     else
         Value = val.Value;
 }
예제 #2
0
        public override int CompareTo(object obj)
        {
            ONTime lVal = obj as ONTime;

            if (lVal == null)
            {
                return(1);
            }

            if (Value == null && lVal.Value == null)
            {
                return(0);
            }

            if (Value == null)
            {
                return(-1);
            }

            if (lVal.Value == null)
            {
                return(1);
            }

            return(TypedValue.CompareTo(lVal.TypedValue));
        }
예제 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="val">Value for this type</param>
 public ONTime(ONTime val)
 {
     if (val == null)
     {
         Value = null;
     }
     else
     {
         Value = val.Value;
     }
 }
예제 #4
0
        public static ONTime Min(ONTime obj1, ONTime obj2)
        {
            if (((object)obj1 == null) || (obj1.Value == null) || ((object)obj2 == null) || (obj2.Value == null))
            {
                throw new ONNullException(null);
            }

            if (TimeSpan.Compare(obj1.TypedValue.TimeOfDay, obj2.TypedValue.TimeOfDay) >= 0)
            {
                return(obj2);
            }
            else
            {
                return(obj1);
            }
        }
예제 #5
0
        public override bool Equals(object obj)
        {
            ONTime lObj = obj as ONTime;

            if ((Value == null) && (lObj.Value == null))
            {
                return(true);
            }

            if ((Value == null) || (lObj.Value == null))
            {
                return(false);
            }

            DateTime lTime1 = TypedValue;
            DateTime lTime2 = lObj.TypedValue;

            return((lTime1.Hour == lTime2.Hour) && (lTime1.Minute == lTime2.Minute) && (lTime1.Second == lTime2.Second) && (lTime1.Millisecond == lTime2.Millisecond));
        }
예제 #6
0
        /// <summary>
        /// Creates XML elements from the data of the system.
        /// </summary>
        /// <param name="xmlWriter">Object with the XML message to add new information and return to client side</param>
        /// <param name="val">Value to be puted inside the XML message</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        /// <param name="xmlElement">Element of the XML that is checked</param>
        public static void ON2XML(XmlWriter xmlWriter, ONTime val, double dtdVersion, string xmlElement)
        {
            if (val == null)
            {
                if (xmlElement == ONXml.XMLTAG_V)
                    xmlWriter.WriteElementString(xmlElement, "");
                else
                    xmlWriter.WriteElementString(ONXml.XMLTAG_NULL, null);
            }
            else
            {
                xmlWriter.WriteStartElement(xmlElement);
                if (xmlElement == ONXml.XMLTAG_OIDFIELD && dtdVersion > 2.0)
                    xmlWriter.WriteAttributeString("Type", "text");

                if (val.TypedValue.Millisecond == 0)
                    xmlWriter.WriteString(val.TypedValue.ToString("HH:mm:ss"));
                else
                    xmlWriter.WriteString(val.TypedValue.ToString("HH:mm:ss.fff"));

                xmlWriter.WriteEndElement();
            }
        }
예제 #7
0
        /// <summary>
        /// Return the seconds of atime
        /// </summary>		
        public static ONInt getSecond(ONTime atime)
        {
            if (atime == null)
                return ONInt.Null;

            return new ONInt(atime.TypedValue.Second);
        }
예제 #8
0
        /// <summary>
        /// Return the minutes of atime
        /// </summary>				
        public static ONInt getMinute(ONTime atime)
        {
            if (atime == null)
                return ONInt.Null;

            return new ONInt(atime.TypedValue.Minute);
        }
예제 #9
0
        /// <summary>
        /// Return the hour of atime
        /// </summary>			
        public static ONInt getHour(ONTime atime)
        {
            if (atime == null)
                return ONInt.Null;

            return new ONInt(atime.TypedValue.Hour);
        }
예제 #10
0
        /// <summary>
        /// Convert the arguments adate and atime to a datetime representation. 
        /// </summary>	
        public static ONDateTime toDateTime(ONDate adate, ONTime atime)
        {
            if (adate == null || atime == null)
                return ONDateTime.Null;

            DateTime lDate = adate.TypedValue;
            DateTime lTime = atime.TypedValue;

            return new ONDateTime(new DateTime(lDate.Year, lDate.Month, lDate.Day, lTime.Hour, lTime.Minute, lTime.Second));
        }
예제 #11
0
        /// <summary>
        /// Return a string representation of the argument atime
        /// </summary>				
        public static ONString timeToString(ONTime atime)
        {
            if (atime == null)
                return ONString.Null;

            return new ONString(atime.TypedValue.ToString("HH:mm:ss"));
        }
예제 #12
0
        /// <summary>
        /// Compare two times for equality
        /// </summary>
        /// <param name="atime1"></param>
        /// <param name="atime2"></param>
        /// <returns>true if and only if the argument atime1 represents the same time as atime2</returns>
        public static ONBool timeEquals(ONTime atime1, ONTime atime2)
        {
            if (atime1 == null || atime2 == null)
                return ONBool.Null;

            return new ONBool(atime1.TypedValue.Equals(atime2.TypedValue));
        }
예제 #13
0
        /// <summary>
        /// Tests if atime1 is before the specified time atime2
        /// </summary>
        /// <returns>true if and only if atime1 is strictly earlier than the time represented by atime2</returns>
        public static ONBool timeBefore(ONTime atime1, ONTime atime2)
        {
            if (atime1 == null || atime2 == null)
                return ONBool.Null;

            return new ONBool(atime1.TypedValue < atime2.TypedValue);
        }
예제 #14
0
        /// <summary>
        /// Returns a time to which a specified time interval has been added.Interval : The interval of time you want to add
        /// </summary>		
        public static ONTime timeAdd(ONString interval, ONInt number, ONTime atime )
        {
            if (interval == null || number == null || atime == null)
                return ONTime.Null;

            switch (interval.TypedValue)
            {
                case "h":
                    return new ONTime(atime.TypedValue.AddHours(number.TypedValue));
                case "n":
                    return new ONTime(atime.TypedValue.AddMinutes(number.TypedValue));
                case "s":
                    return new ONTime(atime.TypedValue.AddSeconds(number.TypedValue));
                default :
                    return atime;
            }
        }
예제 #15
0
        public static ONTime Min(ONTime obj1, ONTime obj2)
        {
            if (((object) obj1 == null) || (obj1.Value == null) ||((object) obj2 == null) || (obj2.Value == null))
                throw new ONNullException(null);

            if (TimeSpan.Compare(obj1.TypedValue.TimeOfDay, obj2.TypedValue.TimeOfDay) >= 0)
                return obj2;
            else
                return obj1;
        }