You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Globalization/IGlobalizationService.cs

55 lines
2.4 KiB

using System.Globalization;
using Connected.Globalization.Languages;
namespace Connected.Globalization;
/// <summary>
/// The service used for globalization related purposes.
/// </summary>
public interface IGlobalizationService
{
/// <summary>
/// Converts an UTC date to a local one base on the current identity and timezone.
/// </summary>
/// <param name="value">The <see cref="DateTime"/> value to be converted.</param>
/// <returns>a <see cref="DateTime"/> value converted to local time.</returns>
DateTime FromUtc(DateTime value);
/// <summary>
/// Converts a local date to an UTC one base on the current identity and timezone.
/// </summary>
/// <param name="value">The <see cref="DateTime"/> value to be converted.</param>
/// <returns>a <see cref="DateTime"/> value converted to UTC time.</returns>
DateTime ToUtc(DateTime value);
/// <summary>
/// Converts an UTC date to a local one base on the current identity and timezone.
/// </summary>
/// <param name="value">The <see cref="DateTimeOffset"/> value to be converted.</param>
/// <returns>a <see cref="DateTimeOffset"/> value converted to local time.</returns>
DateTimeOffset FromUtc(DateTimeOffset value);
/// <summary>
/// Converts a local date to an UTC one base on the current identity and timezone.
/// </summary>
/// <param name="value">The <see cref="DateTimeOffset"/> value to be converted.</param>
/// <returns>a <see cref="DateTimeOffset"/> value converted to UTC time.</returns>
DateTimeOffset ToUtc(DateTimeOffset value);
/// <summary>
/// Returns currently used timezone which is based on the current identity.
/// </summary>
TimeZoneInfo TimeZone { get; }
/// <summary>
/// Returns the converted <see cref="DateTime.UtcNow"/> value to a currently set <see cref="TimeZone"/>.
/// </summary>
DateTimeOffset Now { get; }
/// <summary>
/// Returns the currently active language based on a user identity.
/// </summary>
/// <returns>The <see cref="ILanguage"/> if user has a language set, <code>null</code> otherwise.</returns>
Task<ILanguage?> GetCurrentLanguage();
/// <summary>
/// Returns the currently active <see cref="System.Globalization.CultureInfo"/> based on a user identity.
/// </summary>
/// <returns>The <see cref="System.Globalization.CultureInfo"/> if user has a language set,
/// <see cref="System.Globalization.CultureInfo.InvariantCulture"/> otherwise.</returns>
Task<CultureInfo> GetCurrentCulture();
}