コード例 #1
0
        public void TestToStringCore_Zero_LowerS()
        {
            var value =
                new Timestamp.Value(
                    0,
                    1,
                    1,
                    0,
                    0,
                    0,
                    0
                    );

            Assert.That(
                TimestampStringConverter.ToString(
                    "s",
                    CultureInfo.InvariantCulture,
                    ref value
                    ),
                Is.EqualTo("0000-01-01T00:00:00Z")
                );
        }
コード例 #2
0
        public void TestToStringCore_TimestampMax_LowerS()
        {
            var value =
                new Timestamp.Value(
                    292277026596,
                    12,
                    4,
                    15,
                    30,
                    7,
                    999999999
                    );

            Assert.That(
                TimestampStringConverter.ToString(
                    "s",
                    CultureInfo.InvariantCulture,
                    ref value
                    ),
                Is.EqualTo("292277026596-12-04T15:30:07Z")
                );
        }
コード例 #3
0
        public void TestToStringCore_TimestampMin_LowerS()
        {
            var value =
                new Timestamp.Value(
                    -292277022657,
                    1,
                    27,
                    8,
                    29,
                    52,
                    0
                    );

            Assert.That(
                TimestampStringConverter.ToString(
                    "s",
                    CultureInfo.InvariantCulture,
                    ref value
                    ),
                Is.EqualTo("-292277022657-01-27T08:29:52Z")
                );
        }
コード例 #4
0
        public void TestToStringCore_YearMinus10000_LowerS()
        {
            var value =
                new Timestamp.Value(
                    -10000,
                    10,
                    10,
                    10,
                    10,
                    10,
                    123456789
                    );

            Assert.That(
                TimestampStringConverter.ToString(
                    "s",
                    CultureInfo.InvariantCulture,
                    ref value
                    ),
                Is.EqualTo("-10000-10-10T10:10:10Z")
                );
        }
コード例 #5
0
        public void TestToStringCore_Year10000_UpperO()
        {
            var value =
                new Timestamp.Value(
                    10000,
                    10,
                    10,
                    10,
                    10,
                    10,
                    123456789
                    );

            Assert.That(
                TimestampStringConverter.ToString(
                    "O",
                    CultureInfo.InvariantCulture,
                    ref value
                    ),
                Is.EqualTo("10000-10-10T10:10:10.123456789Z")
                );
        }
コード例 #6
0
        public void TestToStringCore_YearMinus1000_UpperO()
        {
            var value =
                new Timestamp.Value(
                    -1000,
                    1,
                    1,
                    0,
                    0,
                    0,
                    0
                    );

            Assert.That(
                TimestampStringConverter.ToString(
                    "O",
                    CultureInfo.InvariantCulture,
                    ref value
                    ),
                Is.EqualTo("-1000-01-01T00:00:00.000000000Z")
                );
        }
コード例 #7
0
        /// <summary>
        ///		Returns a <see cref="String"/> representation of this instance with the default format and the specified format provider.
        /// </summary>
        /// <param name="format">
        ///		A format string to specify output format. You can specify <c>null</c> for default behavior, which is interpreted as <c>"o"</c>.
        /// </param>
        /// <param name="formatProvider">
        ///		An <see cref="IFormatProvider"/> to provide culture specific format information.
        ///		You can specify <c>null</c> for default behavior, which uses <see cref="CultureInfo.CurrentCulture"/>.
        ///	</param>
        /// <returns>
        ///		A <see cref="String"/> representation of this instance.
        /// </returns>
        /// <exception cref="ArgumentException">
        ///		<paramref name="format"/> is not valid.
        /// </exception>
        /// <remarks>
        ///		<para>
        ///			Currently, only <c>"o"</c> and <c>"O"</c> (ISO 8601 like round trip format) and <c>"s"</c> (ISO 8601 format) are supported.
        ///			Other standard date time format and any custom date time format are not supported.
        ///		</para>
        ///		<para>
        ///			The round trip format is <c>yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffff'Z'</c> which 'fffffffff' nanoseconds.
        ///		</para>
        ///		<para>
        ///			As of recommendation of the msgpack specification and consistency with <see cref="DateTime"/> and <see cref="DateTimeOffset"/>,
        ///			the default value of the <paramref name="format"/> is <c>"o"</c> (ISO 8601 like round-trip format)
        ///			and the default value of the <paramref name="formatProvider"/> is <c>null</c> (<see cref="CultureInfo.CurrentCulture"/>.
        ///			If you want to ensure interoperability for other implementation, specify <c>"s"</c> and <see cref="CultureInfo.InvariantCulture"/> resepectively.
        ///		</para>
        /// </remarks>
        public string ToString(string format, IFormatProvider formatProvider)
        {
            var value = new Value(this);

            return(TimestampStringConverter.ToString(format, formatProvider, ref value));
        }