public void TestGetObjectDateTimeValue() {
   DateTime dateTime = new DateTime();
   Date date = new Date();
   date.year = 2012;
   date.month = 12;
   date.day = 2;
   dateTime.date = date;
   dateTime.hour = 12;
   dateTime.minute = 45;
   dateTime.second = 0;
   dateTime.timeZoneID = "Asia/Shanghai";
   DateTimeValue dateTimeValue = new DateTimeValue();
   dateTimeValue.value = dateTime;
   Assert.AreEqual(dateTime, PqlUtilities.GetValue(dateTimeValue));
 }
    /// <summary>
    /// Converts a System.DateTime object to a Dfp DateTime object with the specified timeZoneId.
    /// Does not perform time zone conversion. This means the returned DateTime value
    /// may not represent the same instant as the System.DateTime value.
    /// </summary>
    /// <param name="dateTime">The DateTime object.</param>
    /// <param name="timeZoneId">The timeZoneId to use.</param>
    /// <returns>A Dfp Datetime object.</returns>
    public static DfpDateTime FromDateTime(System.DateTime dateTime, string timeZoneId) {
      PreconditionUtilities.CheckArgumentNotNull(dateTime, "dateTime");
      PreconditionUtilities.CheckArgumentNotNull(timeZoneId, "timeZoneId");

      DfpDateTime retval = new DfpDateTime();
      retval.date = new Date();
      retval.date.year = dateTime.Year;
      retval.date.month = dateTime.Month;
      retval.date.day = dateTime.Day;
      retval.hour = dateTime.Hour;
      retval.minute = dateTime.Minute;
      retval.second = dateTime.Second;
      retval.timeZoneID = timeZoneId;
      return retval;
    }
        public void TestGetObjectDateSetValue()
        {
            DateTime dateTime = new DateTime();
            Date     date     = new Date();

            date.year  = 2012;
            date.month = 12;
            date.day   = 2;
            DateValue dateValue = new DateValue();

            dateValue.value = date;

            SetValue setValue = new SetValue();

            setValue.values = new Value[] { dateValue };
            List <object> value = PqlUtilities.GetValue(setValue) as List <object>;

            Assert.AreEqual(1, value.Count);
            Assert.True(value.Contains(date));
        }
Ejemplo n.º 4
0
        public void TestGetTextValueDateTimeValue()
        {
            DateTime dateTime = new DateTime();
            Date     date     = new Date();

            date.year           = 2012;
            date.month          = 12;
            date.day            = 2;
            dateTime.date       = date;
            dateTime.hour       = 12;
            dateTime.minute     = 45;
            dateTime.second     = 0;
            dateTime.timeZoneID = "Asia/Shanghai";
            DateTimeValue dateTimeValue = new DateTimeValue();

            dateTimeValue.value = dateTime;

            Row row = new Row();

            row.values = new Value[] { dateTimeValue };
            string[] stringValues = PqlUtilities.GetRowStringValues(row);
            Assert.AreEqual(1, stringValues.Length);
            Assert.AreEqual("2012-12-02T12:45:00 Asia/Shanghai", stringValues[0]);
        }
 /// <summary>
 /// Adds a new DateTime value to the list of query parameters.
 /// </summary>
 /// <param name="key">The parameter name.</param>
 /// <param name="value">The parameter value.</param>
 /// <returns>The statement builder, for chaining method calls.</returns>
 public StatementBuilder AddValue(string key, DateTime value) {
   DateTimeValue queryValue = new DateTimeValue();
   queryValue.value = value;
   return AddValue(key, queryValue);
 }
    public void TestGetObjectDateTimeSetValue() {
      DateTime dateTime = new DateTime();
      Date date = new Date();
      date.year = 2012;
      date.month = 12;
      date.day = 2;
      dateTime.date = date;
      dateTime.hour = 12;
      dateTime.minute = 45;
      dateTime.second = 0;
      dateTime.timeZoneID = "Asia/Shanghai";
      DateTimeValue dateTimeValue = new DateTimeValue();
      dateTimeValue.value = dateTime;

      SetValue setValue = new SetValue();
      setValue.values = new Value[] { dateTimeValue };
      List<object> value = PqlUtilities.GetValue(setValue) as List<object>;
      Assert.AreEqual(1, value.Count);
      Assert.True(value.Contains(dateTime));
    }
    public void TestGetObjectDateSetValue() {
      DateTime dateTime = new DateTime();
      Date date = new Date();
      date.year = 2012;
      date.month = 12;
      date.day = 2;
      DateValue dateValue = new DateValue();
      dateValue.value = date;

      SetValue setValue = new SetValue();
      setValue.values = new Value[] { dateValue };
      List<object> value = PqlUtilities.GetValue(setValue) as List<object>;
      Assert.AreEqual(1, value.Count);
      Assert.True(value.Contains(date));
    }