public void DateTimeOffset_Can_Specifity_Your_Local_Time_From_Utc_Point_Of_View()
        {
            var jonsTime = new DateTimeOffset(2011, 4, 1, 21, 24, 0, TimeSpan.FromHours(1));
            var localTime = new DateTime(2011, 4, 1, 20, 24, 0);

            Assert.That(jonsTime.ToUniversalTime().Hour, Is.EqualTo(localTime.Hour));
        }
Example #2
0
 internal static string ToAtomString(DateTimeOffset dateTime)
 {
     if (dateTime.Offset == zeroOffset)
     {
         return dateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
     }
     return dateTime.ToString("yyyy-MM-ddTHH:mm:sszzz", CultureInfo.InvariantCulture);
 }
 private string AsString(DateTimeOffset dateTime)
 {
     if (dateTime.Offset == zeroOffset)
     {
         return dateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
     }
     return dateTime.ToString("yyyy-MM-ddTHH:mm:sszzz", CultureInfo.InvariantCulture);
 }
 public void WriteDate(DateTimeOffset datetime)
 {
     this.writeAmf3Type(Amf3Type.Date);
     UInt29 remainIndex = 0;
     remainIndex.WriteAsRefTo(false,this.writer_);
     var utcTime = datetime.ToUniversalTime();
     var totalMilliseconds = utcTime.ToUnixTime();
     this.writer_.WriteDouble(totalMilliseconds);
 }
        public void ConvertDateTimeValue_NonStandardPrimitives_DefaultTimeZoneInfo(DateTimeOffset valueToConvert)
        {
            // Arrange & Act
            TimeZoneInfoHelper.TimeZone = null;
            object actual = EdmPrimitiveHelpers.ConvertPrimitiveValue(valueToConvert, typeof(DateTime));

            // Assert
            DateTime dt = Assert.IsType<DateTime>(actual);
            Assert.Equal(valueToConvert.ToUniversalTime().ToOffset(TimeZoneInfo.Local.BaseUtcOffset).DateTime, dt);
        }
        public void DateTimeOffSet()
        {
            //System.DateTimeOffset (.NET 2.0SP1 / .NET 3.5)

            DateTimeOffset myTime = new DateTimeOffset(2015, 11, 12, 9, 13, 0, TimeSpan.FromHours(1));
            Console.WriteLine(  myTime);
            Console.WriteLine(myTime.ToUniversalTime());

            //System.TimeZoneInfo (.NET 3.5)
        }
        public void ConvertDateTimeValue_NonStandardPrimitives_CustomTimeZoneInfo(DateTimeOffset valueToConvert)
        {
            // Arrange & Act
            TimeZoneInfoHelper.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
            object actual = EdmPrimitiveHelpers.ConvertPrimitiveValue(valueToConvert, typeof(DateTime));

            // Assert
            DateTime dt = Assert.IsType<DateTime>(actual);
            Assert.Equal(valueToConvert.ToUniversalTime().ToOffset(new TimeSpan(-8, 0, 0)).DateTime, dt);
        }
 private string AsString(DateTimeOffset dateTime)
 {
     if (dateTime.Offset == Atom10FeedFormatter.zeroOffset)
     {
         return dateTime.ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss Z", CultureInfo.InvariantCulture);
     }
     StringBuilder builder = new StringBuilder(dateTime.ToString("ddd, dd MMM yyyy HH:mm:ss zzz", CultureInfo.InvariantCulture));
     builder.Remove(builder.Length - 3, 1);
     return builder.ToString();
 }
Example #9
0
 public static XElement TIME(string name, DateTimeOffset time)
 {
     var t1 = time.ToUniversalTime();
     var t2 = time.ToLocalTime().ToString("G");
     return new XElement(
         XN.time,
         PROP(name),
         new XAttribute(XN.datetime, t1),
         t2);
 }
Example #10
0
        public UserList(string usersFile, DateTimeOffset startOfWeek)
            : this(usersFile)
        {
            StartOfPeriod = startOfWeek.ToUniversalTime();
            EndOfPeriod = StartOfPeriod.AddDays(7);

            // We only count events attached to posts (questions or answers) that we created at most 3 days before
            // the week starts. The idea is to not keep rewarding users for old entries that are getting upticks
            FirstStackOverflowPost = QueryHelpers.GetIdOfFirstPostOfDay(StartOfPeriod.AddDays(-3));
        }
Example #11
0
        public void DateTimeOffset()
        {
            // System.DateTimeOffset (.NET 3.5)
            DateTimeOffset axelsTime = new DateTimeOffset(2011, 4, 1, 21, 24, 0, TimeSpan.FromHours(1));
            //Console.WriteLine(axelsTime);
            //Console.WriteLine(axelsTime.ToUniversalTime());
            DateTimeOffset robsTime = new DateTimeOffset(2011, 4, 1, 10, 24, 0, TimeSpan.FromHours(-10));

            Assert.AreEqual(axelsTime, robsTime);
            Assert.AreEqual(axelsTime.ToUniversalTime(), robsTime.ToUniversalTime());
        }
Example #12
0
        public WaitHandle AbsoluteTimer(DateTimeOffset expireAt)
        {
            var handle = CreateWaitableTimer(IntPtr.Zero, true, null);

            var dueTime = expireAt.ToUniversalTime().ToFileTime();

            SetWaitableTimer(handle, ref dueTime, 0, IntPtr.Zero, IntPtr.Zero, false);

            var safeHandle = new SafeWaitHandle(handle, true);

            return new TimerWaitHandle(safeHandle);
        }
        public void CopyFromDocument()
        {
            var mapper = CreateMapper();

            var doc = new Document();

            var ts = new DateTimeOffset(new DateTime(2013, 1, 1));
            doc.Add(new Field("TimeStampOffset", ts.ToUniversalTime().Ticks.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));

            mapper.CopyFromDocument(doc, 0, this);

            Assert.That(TimeStampOffset, Is.EqualTo(ts));
        }
Example #14
0
        public modified()
        {
            point_in_time = new DateTimeOffset(2011,09,24,22,00,0,0, 2.Hours());

            // last-modified: 24 Sep 2011 23:11:00 +0200 (21:00:00 GMT)
            given_resource(
                "/resource",
                resource=>resource.Map<ResourceWithLastModified>().LastModified(_=> _.LastModified),
                new ResourceWithLastModified { LastModified = point_in_time + 1.Hours() });

            // if-modified-since: 24 Sep 2011 22:00:00 +0200 (20:00:00 GMT)
            given_request_header("if-modified-since", point_in_time.ToUniversalTime().ToString("R"));
            when_executing_request("/resource");
        }
 private string DateTimeSerializeToJSON(DateTime dateTime)
 {
     var value = new DateTimeOffset(dateTime);
     var kind = dateTime.Kind;
     var num = ((value.ToUniversalTime().Ticks - new DateTime(0x7b2, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks) / 0x2710L);
     var str = string.Empty;
     switch (kind)
     {
         case DateTimeKind.Unspecified:
         case DateTimeKind.Local:
             TimeSpan offset = value.Offset;
             str = offset.Hours.ToString("+00;-00", CultureInfo.InvariantCulture) + offset.Minutes.ToString("00;00", CultureInfo.InvariantCulture);
             break;
     }
     return ("\"\\/Date(" + num.ToString(CultureInfo.InvariantCulture) + str + ")\\/\"");
 }
        public async Task Defer(DateTimeOffset approximateDueTime, Dictionary<string, string> headers, byte[] body)
        {
            using (var connection = await _connectionHelper.GetConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = string.Format(@"
INSERT INTO ""{0}"" (""due_time"", ""headers"", ""body"") VALUES (@due_time, @headers, @body)", _tableName);

                    command.Parameters.Add("due_time", NpgsqlDbType.Timestamp).Value = approximateDueTime.ToUniversalTime().DateTime;
                    command.Parameters.Add("headers", NpgsqlDbType.Text).Value = _headerSerializer.SerializeToString(headers);
                    command.Parameters.Add("body", NpgsqlDbType.Bytea).Value = body;

                    await command.ExecuteNonQueryAsync();
                }

                connection.Complete();
            }
        }
Example #17
0
		/// <summary>
		///		Convert specified <see cref="DateTimeOffset"/> to <see cref="Int64"/> as MessagePack defacto-standard.
		/// </summary>
		/// <param name="value"><see cref="DateTimeOffset"/>.</param>
		/// <returns>
		///		UTC epoc time from 1970/1/1 0:00:00, in milliseconds.
		/// </returns>
		public static long FromDateTimeOffset( DateTimeOffset value )
		{
			return ( long )value.ToUniversalTime().Subtract( _unixEpocUtc ).TotalMilliseconds;
		}
Example #18
0
 public static string DateToString(DateTimeOffset dateTime)
 {
     return dateTime.ToUniversalTime().ToString("r", (IFormatProvider)CultureInfo.InvariantCulture);
 }
        public void TestSerializeDateTimeOffset()
        {
            var value = new DateTimeOffset(new DateTime(2010, 10, 8, 11, 29, 0), TimeSpan.FromHours(-4));
            var isoDate = value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.FFFZ");
            var obj = new TestClass {
                A = value,
                D = value,
                S = value
            };
            var json = obj.ToJson();
            var expected = "{ 'A' : #A, 'D' : #D, 'S' : '#S' }";
            expected = expected.Replace("#A", string.Format("[NumberLong('{0}'), {1}]", value.DateTime.Ticks, value.Offset.TotalMinutes));
            expected = expected.Replace("#D",
                "{ 'DateTime' : ISODate('#D'), 'Ticks' : NumberLong('#T'), 'Offset' : #O }"
                    .Replace("#D", isoDate)
                    .Replace("#T", value.DateTime.Ticks.ToString())
                    .Replace("#O", XmlConvert.ToString(value.Offset.TotalMinutes))
            );
            expected = expected.Replace("#S", "2010-10-08T11:29:00-04:00");
            expected = expected.Replace("'", "\"");
            Assert.AreEqual(expected, json);

            var bson = obj.ToBson();
            var rehydrated = BsonSerializer.Deserialize<TestClass>(bson);
            Assert.IsTrue(bson.SequenceEqual(rehydrated.ToBson()));
        }
        internal static object ConvertUnsupportedPrimitives(object value)
        {
            if (value != null)
            {
                Type type = value.GetType();

                // Note that type cannot be a nullable type as value is not null and it is boxed.
                switch (Type.GetTypeCode(type))
                {
                    case TypeCode.Char:
                        return new String((char)value, 1);

                    case TypeCode.UInt16:
                        return (int)(ushort)value;

                    case TypeCode.UInt32:
                        return (long)(uint)value;

                    case TypeCode.UInt64:
                        return checked((long)(ulong)value);

                    case TypeCode.DateTime:
                        DateTime dateTime = (DateTime)value;
                        TimeZoneInfo timeZone = TimeZoneInfoHelper.TimeZone;
                        if (dateTime.Kind == DateTimeKind.Utc || dateTime.Kind == DateTimeKind.Local)
                        {
                            return new DateTimeOffset(dateTime.ToUniversalTime()).ToOffset(timeZone.BaseUtcOffset);
                        }

                        DateTimeOffset dateTimeOffset = new DateTimeOffset(dateTime, timeZone.GetUtcOffset(dateTime));
                        return dateTimeOffset.ToUniversalTime().ToOffset(timeZone.BaseUtcOffset);

                    default:
                        if (type == typeof(char[]))
                        {
                            return new String(value as char[]);
                        }
                        else if (type == typeof(XElement))
                        {
                            return ((XElement)value).ToString();
                        }
                        else if (type == typeof(Binary))
                        {
                            return ((Binary)value).ToArray();
                        }
                        break;
                }
            }

            return value;
        }
 private static string ExpectedDateTimeOffsetSerialization(DateTimeOffset dto)
 {
     DateTime utc = dto.ToUniversalTime().UtcDateTime;
     return "\"" + utc.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", CultureInfo.InvariantCulture) + "\"";
 }
Example #22
0
		/// <summary>
		///		Convert specified <see cref="DateTimeOffset"/> to <see cref="Int64"/> as MessagePack defacto-standard.
		/// </summary>
		/// <param name="value"><see cref="DateTimeOffset"/>.</param>
		/// <returns>
		///		UTC epoc time from 1970/1/1 0:00:00, in milliseconds.
		/// </returns>
		public static long FromDateTimeOffset( DateTimeOffset value )
		{
			// Note: microseconds and nanoseconds should always truncated, so deviding by integral is suitable.
			return value.ToUniversalTime().Subtract( _unixEpocUtc ).Ticks / _ticksToMilliseconds;
		}
 private string FormatDateTime(DateTimeOffset dateTime)
 {
     return string.Format(CultureInfo.InvariantCulture, "{0:O}", dateTime.ToUniversalTime());
 }
Example #24
0
 public static string DateToString(DateTimeOffset dateTime)
 {
     // Format according to RFC1123; 'r' uses invariant info (DateTimeFormatInfo.InvariantInfo)
     return dateTime.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture);
 }
Example #25
0
 internal static string DateToString(DateTimeOffset dateTime)
 {
     return dateTime.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture);
 }
        /// <summary>
        /// Returns an enumerable collection of log blobs containing Analytics log records. The blobs are retrieved lazily.
        /// </summary>
        /// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
        /// <param name="startTime">A <see cref="DateTimeOffset"/> object representing the start of the time range for which logs should be retrieved.</param>
        /// <param name="endTime">A <see cref="DateTimeOffset"/> object representing the end of the time range for which logs should be retrieved.</param>
        /// <param name="operations">A <see cref="LoggingOperations"/> enumeration value that indicates the types of logging operations on which to filter the log blobs.</param>
        /// <param name="details">A <see cref="BlobListingDetails"/> enumeration value that indicates whether or not blob metadata should be returned. Only <c>None</c> and <c>Metadata</c> are valid values. </param>
        /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
        /// <returns>An enumerable collection of objects that implement <see cref="ICloudBlob"/> and are retrieved lazily.</returns>
        /// <remarks>Note that specifying a logging operation type for the <paramref name="operations"/> parameter will return any Analytics log blob that contains the specified logging operation,
        /// even if that log blob also includes other types of logging operations. Also note that the only currently supported values for the <paramref name="details"/> 
        /// parameter are <c>None</c> and <c>Metadata</c>.</remarks>
        public IEnumerable<ICloudBlob> ListLogs(StorageService service, DateTimeOffset startTime, DateTimeOffset? endTime, LoggingOperations operations, BlobListingDetails details, BlobRequestOptions options, OperationContext operationContext)
        {
            CloudBlobDirectory logDirectory = this.GetLogDirectory(service);
            BlobListingDetails metadataDetails = details;
            DateTimeOffset utcStartTime = startTime.ToUniversalTime();
            DateTimeOffset dateCounter = new DateTimeOffset(utcStartTime.Ticks - (utcStartTime.Ticks % TimeSpan.TicksPerHour), utcStartTime.Offset);
            DateTimeOffset? utcEndTime = null;
            string endPrefix = null;

            // Ensure that the date range is correct.
            if (endTime.HasValue)
            {
                utcEndTime = endTime.Value.ToUniversalTime();
                endPrefix = logDirectory.Prefix + utcEndTime.Value.ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture);
                if (utcStartTime > utcEndTime.Value)
                {
                    string errorString = string.Format(CultureInfo.InvariantCulture, SR.StartTimeExceedsEndTime, startTime, endTime.Value);
                    throw new ArgumentException(errorString);
                }
            }

            // Currently only support the ability to retrieve metadata on logs.
            if (details.HasFlag(BlobListingDetails.Copy) || details.HasFlag(BlobListingDetails.Snapshots) || details.HasFlag(BlobListingDetails.UncommittedBlobs))
            {
                throw new ArgumentException(SR.InvalidListingDetails);
            }

            // At least one LogType must be specified.
            if (operations == LoggingOperations.None)
            {
                throw new ArgumentException(SR.InvalidLoggingLevel);
            }

            // If metadata or a specific LogType is specified, metadata should be retrieved.
            if (details.HasFlag(BlobListingDetails.Metadata) || !operations.HasFlag(LoggingOperations.All))
            {
                metadataDetails = BlobListingDetails.Metadata;
            }

            // Check logs using an hour-based prefix until we reach a day boundary.
            while (dateCounter.Hour > 0)
            {
                string currentPrefix = logDirectory.Prefix + dateCounter.ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture);
                IEnumerable<IListBlobItem> currentLogs = logDirectory.Container.ListBlobs(currentPrefix, true, metadataDetails, options, operationContext);

                foreach (ICloudBlob log in currentLogs)
                {
                    if (!utcEndTime.HasValue || string.Compare(log.Parent.Prefix, endPrefix) <= 0)
                    {
                        if (IsCorrectLogType(log, operations))
                        {
                            yield return log;
                        }
                    }
                    else
                    {
                        yield break;
                    }
                }

                dateCounter = dateCounter.AddHours(1);
                if (dateCounter > DateTimeOffset.UtcNow.AddHours(1))
                {
                    yield break;
                }
            }

            // Check logs using a day-based prefix until we reach a month boundary.
            while (dateCounter.Day > 1)
            {
                string currentPrefix = logDirectory.Prefix + dateCounter.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture);
                IEnumerable<IListBlobItem> currentLogs = logDirectory.Container.ListBlobs(currentPrefix, true, metadataDetails, options, operationContext);

                foreach (ICloudBlob log in currentLogs)
                {
                    if (!utcEndTime.HasValue || string.Compare(log.Parent.Prefix, endPrefix) <= 0)
                    {
                        if (IsCorrectLogType(log, operations))
                        {
                            yield return log;
                        }
                    }
                    else
                    {
                        yield break;
                    }
                }

                dateCounter = dateCounter.AddDays(1);
                if (dateCounter > DateTimeOffset.UtcNow.AddHours(1))
                {
                    yield break;
                }
            }

            // Check logs using a month-based prefix until we reach a year boundary.
            while (dateCounter.Month > 1)
            {
                string currentPrefix = logDirectory.Prefix + dateCounter.ToString("yyyy/MM", CultureInfo.InvariantCulture);
                IEnumerable<IListBlobItem> currentLogs = logDirectory.Container.ListBlobs(currentPrefix, true, metadataDetails, options, operationContext);

                foreach (ICloudBlob log in currentLogs)
                {
                    if (!utcEndTime.HasValue || string.Compare(log.Parent.Prefix, endPrefix) <= 0)
                    {
                        if (IsCorrectLogType(log, operations))
                        {
                            yield return log;
                        }
                    }
                    else
                    {
                        yield break;
                    }
                }

                dateCounter = dateCounter.AddMonths(1);
                if (dateCounter > DateTimeOffset.UtcNow.AddHours(1))
                {
                    yield break;
                }
            }

            // Continue using a year-based prefix. 
            while (true)
            {
                string currentPrefix = logDirectory.Prefix + dateCounter.ToString("yyyy", CultureInfo.InvariantCulture);
                IEnumerable<IListBlobItem> currentLogs = logDirectory.Container.ListBlobs(currentPrefix, true, metadataDetails, options, operationContext);

                foreach (ICloudBlob log in currentLogs)
                {
                    if (!utcEndTime.HasValue || string.Compare(log.Parent.Prefix, endPrefix) <= 0)
                    {
                        if (IsCorrectLogType(log, operations))
                        {
                            yield return log;
                        }
                    }
                    else
                    {
                        yield break;
                    }
                }

                dateCounter = dateCounter.AddYears(1);
                if (dateCounter > DateTimeOffset.UtcNow.AddHours(1))
                { 
                    yield break;
                }
            }
        }
Example #27
0
        public void TimestampTz()
        {
            var tzOffset = TimeZoneInfo.Local.BaseUtcOffset;
            if (tzOffset == TimeSpan.Zero)
                TestUtil.Inconclusive("Test cannot run when machine timezone is UTC");

            var dateTimeUtc = new DateTime(2015, 1, 27, 8, 45, 12, 345, DateTimeKind.Utc);
            var dateTimeLocal = dateTimeUtc.ToLocalTime();
            var dateTimeUnspecified = new DateTime(dateTimeUtc.Ticks, DateTimeKind.Unspecified);

            var nDateTimeUtc = new NpgsqlDateTime(dateTimeUtc);
            var nDateTimeLocal = nDateTimeUtc.ToLocalTime();
            var nDateTimeUnspecified = new NpgsqlDateTime(nDateTimeUtc.Ticks, DateTimeKind.Unspecified);

            var dateTimeOffset = new DateTimeOffset(dateTimeLocal, tzOffset);

            using (var cmd = new NpgsqlCommand("SELECT @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9", Conn))
            {
                cmd.Parameters.AddWithValue("p1", NpgsqlDbType.TimestampTZ, dateTimeUtc);
                cmd.Parameters.AddWithValue("p2", NpgsqlDbType.TimestampTZ, dateTimeLocal);
                cmd.Parameters.AddWithValue("p3", NpgsqlDbType.TimestampTZ, dateTimeUnspecified);
                cmd.Parameters.AddWithValue("p4", NpgsqlDbType.TimestampTZ, nDateTimeUtc);
                cmd.Parameters.AddWithValue("p5", NpgsqlDbType.TimestampTZ, nDateTimeLocal);
                cmd.Parameters.AddWithValue("p6", NpgsqlDbType.TimestampTZ, nDateTimeUnspecified);
                cmd.Parameters.AddWithValue("p7", dateTimeUtc);
                cmd.Parameters.AddWithValue("p8", nDateTimeUtc);
                cmd.Parameters.AddWithValue("p9", dateTimeOffset);

                using (var reader = cmd.ExecuteReader())
                {
                    reader.Read();

                    for (var i = 0; i < cmd.Parameters.Count; i++)
                    {
                        // Regular type (DateTime)
                        Assert.That(reader.GetFieldType(i), Is.EqualTo(typeof(DateTime)));
                        Assert.That(reader.GetDateTime(i), Is.EqualTo(dateTimeUtc));
                        Assert.That(reader.GetFieldValue<DateTime>(i).Kind, Is.EqualTo(DateTimeKind.Utc));
                        Assert.That(reader[i], Is.EqualTo(dateTimeUtc));
                        Assert.That(reader.GetValue(i), Is.EqualTo(dateTimeUtc));

                        // Provider-specific type (NpgsqlDateTime)
                        Assert.That(reader.GetTimeStamp(i), Is.EqualTo(nDateTimeUtc));
                        Assert.That(reader.GetProviderSpecificFieldType(i), Is.EqualTo(typeof(NpgsqlDateTime)));
                        Assert.That(reader.GetProviderSpecificValue(i), Is.EqualTo(nDateTimeUtc));
                        Assert.That(reader.GetFieldValue<NpgsqlDateTime>(i), Is.EqualTo(nDateTimeUtc));

                        // DateTimeOffset
                        Assert.That(reader.GetFieldValue<DateTimeOffset>(i), Is.EqualTo(dateTimeOffset.ToUniversalTime()));
                    }
                }
            }
        }
 /// <summary>
 /// Converts a DateTimeOffset object to unix time.
 /// </summary>
 /// <param name="dateTime">The date time.</param>
 /// <returns>The unix date time.</returns>
 public static double ToUnixTime(DateTimeOffset dateTime)
 {
     Contract.Requires(dateTime >= Epoch);
     return (dateTime.ToUniversalTime() - Epoch).TotalSeconds;
 }
 private static void AssertApproximatelyEqual(DateTimeOffset actual, DateTimeOffset expected)
 {
     Assert.InRange( actual.ToUniversalTime() - expected.ToUniversalTime(), TimeSpan.FromSeconds(-1), TimeSpan.FromSeconds(1));
 }
        /// <summary>
        /// Converts the given DateTimeOffset value to string appropriate for Atom format.
        /// </summary>
        /// <param name="dateTime">Given DateTimeOffset value.</param>
        /// <returns>Atom format string representation of <paramref name="dateTime"/>.</returns>
        internal static string ToString(DateTimeOffset dateTime)
        {
            DebugUtils.CheckNoExternalCallers();

            if (dateTime.Offset == zeroOffset)
            {
                return dateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
            }

            return dateTime.ToString("yyyy-MM-ddTHH:mm:sszzz", CultureInfo.InvariantCulture);
        }