microsoft/healthcare-shared-components

Public

mirrored from https://github.com/microsoft/healthcare-shared-componentsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.0.0-1.0.79

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

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
6using System;
7
8namespace 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