microsoft/healthcare-shared-components
Publicmirrored from https://github.com/microsoft/healthcare-shared-componentsAvailable
src/Microsoft.Health.Core/Extensions/DateTimeExtensions.cs
22lines · modecode
| 1 | // ------------------------------------------------------------------------------------------------- |
| 2 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. |
| 4 | // ------------------------------------------------------------------------------------------------- |
| 5 | |
| 6 | using System; |
| 7 | |
| 8 | namespace Microsoft.Health.Core.Extensions |
| 9 | { |
| 10 | public static class DateTimeExtensions |
| 11 | { |
| 12 | /// <summary> |
| 13 | /// Truncates a DateTime to millisecond precision |
| 14 | /// </summary> |
| 15 | /// <param name="dateTime">The DateTime</param> |
| 16 | /// <returns>The truncated dateTime</returns> |
| 17 | public static DateTime TruncateToMillisecond(this DateTime dateTime) |
| 18 | { |
| 19 | return new DateTime(dateTime.Ticks / TimeSpan.TicksPerMillisecond * TimeSpan.TicksPerMillisecond, dateTime.Kind); |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |