NuoDb.Data.Client.EncodedDataStream.encodeTimestamp C# (CSharp) Method

encodeTimestamp() public method

public encodeTimestamp ( DateTime val ) : void
val DateTime
return void
        public virtual void encodeTimestamp(DateTime val)
        {
            if (val == null)
            {
                write(edsNull);

                return;
            }

            TimeSpan delta = val.ToUniversalTime() - baseDate;
            long value = delta.Ticks * NANOSECONDS_PER_TICK; // convert to nanoseconds
            int count = byteCount(value);

            write(edsNanoSecLen1 + count - 1);

            for (int shift = (count - 1) * 8; shift >= 0; shift -= 8)
            {
                write((int)(value >> shift));
            }
        }

Usage Example

Esempio n. 1
0
 internal override void encodeValue(EncodedDataStream dataStream)
 {
     dataStream.encodeTimestamp(value);
 }