Exemplo n.º 1
0
        public void Test_GDMDateItemAsIConvertible()
        {
            var dtx1 = new GDMDateValue();

            dtx1.ParseString("05 JAN 2013");
            IConvertible dtItem1 = new GDMDateItem(dtx1);

            Assert.AreEqual(TypeCode.Object, dtItem1.GetTypeCode());
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToBoolean(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToChar(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToSByte(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToByte(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToInt16(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToUInt16(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToInt32(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToUInt32(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToInt64(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToUInt64(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToSingle(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToDouble(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToDecimal(null); });
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToDateTime(null); });
            Assert.AreEqual("05.01.2013", dtItem1.ToString(null));
            Assert.Throws(typeof(NotImplementedException), () => { dtItem1.ToType(typeof(Int32), null); });
        }
Exemplo n.º 2
0
        public void Test_GDMDateItem_Common()
        {
            var dtx1 = new GDMDateValue();

            dtx1.ParseString("05 JAN 2013");
            var dtItem1 = new GDMDateItem(dtx1);

            Assert.AreEqual("05.01.2013", dtItem1.ToString());

            var dtx2 = new GDMDateValue();

            dtx2.ParseString("17 FEB 2013");
            var dtItem2 = new GDMDateItem(dtx2);

            Assert.AreEqual("17.02.2013", dtItem2.ToString());

            Assert.AreEqual(0, dtItem1.CompareTo(dtItem1));
            Assert.AreEqual(-1, dtItem1.CompareTo(dtItem2));
            Assert.AreEqual(-1, dtItem1.CompareTo(null));
            Assert.AreEqual(+1, dtItem2.CompareTo(dtItem1));

            dtItem1 = new GDMDateItem(dtx1);
            dtItem2 = new GDMDateItem(null);
            Assert.AreEqual(-1, dtItem1.CompareTo(dtItem2));

            dtItem1 = new GDMDateItem(null);
            dtItem2 = new GDMDateItem(dtx2);
            Assert.AreEqual(+1, dtItem1.CompareTo(dtItem2));

            dtItem1 = new GDMDateItem(null);
            dtItem2 = new GDMDateItem(null);
            Assert.AreEqual(0, dtItem1.CompareTo(dtItem2));
        }
Exemplo n.º 3
0
        public GDMDateValue GetActualDates()
        {
            var result = new GDMDateValue();

            result.ParseString(ActualDates);
            return(result);
        }
Exemplo n.º 4
0
 public Event(GDMDateValue date, string evType, string description, string overview, string note,
              bool important, bool capitalise)
 {
     fPreference = EventPreference.Unknown;
     fDate       = date;
     if (capitalise)
     {
         GMHelper.Capitalise(ref description);
     }
     if (description.Length > 0)
     {
         if (description[description.Length - 1] == '.')
         {
             fDescription = description.Substring(0, description.Length - 1);
         }
         else
         {
             fDescription = description;
         }
     }
     fOverview  = overview;
     fImportant = important;
     fNote      = note;
     if (note == "")
     {
         fNote = null;
     }
     fType = evType;
 }
Exemplo n.º 5
0
        public void SetActualDates(GDMDateValue value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            ActualDates = value.StringValue;
        }
Exemplo n.º 6
0
        public static int GetEventsYearsDiff(GDMDateValue ev1, GDMDateValue ev2, bool currentEnd = true)
        {
            int result = -1;

            try {
                int dt1 = GetChronologicalYear(ev1);
                int dt2 = GetChronologicalYear(ev2);

                if (currentEnd && dt2 == 0)
                {
                    dt2 = DateTime.Now.Year;
                }

                if (dt1 != 0 && dt2 != 0)
                {
                    result = Math.Abs(dt2 - dt1);
                }
            } catch (Exception ex) {
                Logger.WriteError("GKUtils.GetEventsYearsDiff()", ex);
            }

            return(result);
        }
Exemplo n.º 7
0
 public CListableYear(GDMDateValue date)
 {
     fDate     = date;
     base.Text = ToString();
 }
Exemplo n.º 8
0
 public QualifiedDate(GDMDateValue date, DateQualification qualification)
 {
     Date          = date;
     Qualification = qualification;
 }
Exemplo n.º 9
0
 public static int GetChronologicalYear(GDMDateValue dateVal)
 {
     return((dateVal == null) ? 0 : dateVal.GetChronologicalYear());
 }
Exemplo n.º 10
0
 public OccupationCounter(string name, GDMDateValue date)
 {
     Name = name;
     Date = date;
 }