Esempio n. 1
0
 public void String8_FromDateTime()
 {
     byte[] buffer = new byte[20];
     Assert.AreEqual("0001-01-01", String8.FromDateTime(DateTime.MinValue, buffer).ToString());
     Assert.AreEqual("2017-02-14", String8.FromDateTime(new DateTime(2017, 02, 14, 0, 0, 0, DateTimeKind.Utc), buffer).ToString());
     Assert.AreEqual("2017-02-14T01:02:03Z", String8.FromDateTime(new DateTime(2017, 02, 14, 1, 2, 3, DateTimeKind.Utc), buffer).ToString());
     Assert.AreEqual("9999-12-31T23:59:59Z", String8.FromDateTime(DateTime.MaxValue, buffer).ToString());
 }
Esempio n. 2
0
 public void WriteValuePart(DateTime value)
 {
     if (!_inPartialColumn)
     {
         throw new InvalidOperationException("WriteValueStart must be called before WriteValuePart.");
     }
     String8.FromDateTime(value, _typeConversionBuffer).WriteTo(_stream);
 }
Esempio n. 3
0
 public void Write(DateTime value)
 {
     // DateTimes are quoted but never need escaping. "ColumnName": "2017-05-03T12:43:21Z"
     WriteColumnSeparator();
     _stream.WriteByte(UTF8.Quote);
     String8.FromDateTime(value, _typeConversionBuffer).WriteTo(_stream);
     _stream.WriteByte(UTF8.Quote);
 }
Esempio n. 4
0
 public void Write(DateTime value)
 {
     Write(String8.FromDateTime(value, _convertBuffer, 0));
 }
 /// <summary>
 ///  Write a UTC DateTime as part of a single cell value.
 ///  Callers must call WriteValueStart and WriteValueEnd around WriteValuePart calls.
 /// </summary>
 /// <param name="part">Value to write</param>
 public void WriteValuePart(DateTime part)
 {
     WriteValuePart(String8.FromDateTime(part, _typeConversionBuffer));
 }
 /// <summary>
 ///  Write a single DateTime [UTC] to the current row.
 ///  The value is converted without allocations.
 /// </summary>
 /// <param name="value">Value to write</param>
 public void Write(DateTime value)
 {
     Write(String8.FromDateTime(value, _typeConversionBuffer));
 }