29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
|
|
namespace Kreta.Naplo.Domain.V3.Utility
|
|
{
|
|
public static class Extensions
|
|
{
|
|
/// UTC: 2016-10-30T20:00:00Z
|
|
/// Local: 2016-10-30T23:00:00+01:00
|
|
/// Unspecified: 2016-10-30T22:00:00
|
|
public static DateTime ToIso8601Utc(this DateTime dt)
|
|
=> new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Kind).ToUniversalTime();
|
|
|
|
/// UTC: 2016-10-30T20:00:00Z
|
|
/// Local: 2016-10-30T23:00:00+01:00
|
|
/// Unspecified: 2016-10-30T22:00:00
|
|
public static string ToIso8601UtcString(this DateTime dt)
|
|
=> dt.ToString("yyyy-MM-dd'T'HH:mm:ssK", CultureInfo.InvariantCulture);
|
|
|
|
public static IEnumerable<TOutput> ConvertAll<TInput, TOutput>(this IEnumerable<TInput> collection, Converter<TInput, TOutput> converter)
|
|
{
|
|
foreach (TInput item in collection)
|
|
{
|
|
yield return converter.Invoke(item);
|
|
}
|
|
}
|
|
}
|
|
}
|