• Articles
  • API Documentation
  • GitHub
  • Abhith
  • API Documentation
  • Code.Library.Extensions
  • DateTimeExtensions

    Show / Hide Table of Contents
    • Code.Library
      • Breadcrumb
      • BreadcrumbNode
      • IAuditedObject
      • IAuditedObject<TUser>
      • ICreationAuditedObject
      • ICreationAuditedObject<TCreator>
      • IDeletionAuditedObject
      • IDeletionAuditedObject<TUser>
      • IHasCreationTime
      • IHasDeletionTime
      • IHasModificationTime
      • IMayHaveCreator
      • IMayHaveCreator<TCreator>
      • IModificationAuditedObject
      • IModificationAuditedObject<TUser>
      • IResult
      • ISoftDelete
      • Result
      • Result<T>
      • Result<T, E>
      • ResultFailureException
      • ResultFailureException<E>
      • ResultSuccessException
    • Code.Library.Application.Behaviors
      • LoggingBehavior<TRequest, TResponse>
      • RequestPerformanceBehavior<TRequest, TResponse>
      • UnhandledExceptionBehavior<TRequest, TResponse>
    • Code.Library.AspNetCore
      • PerfTracker
      • ServiceCollectionExtensions
    • Code.Library.AspNetCore.Attributes
      • LogUsageAttribute
    • Code.Library.AspNetCore.Extensions
      • HealthCheckEndpointRouteBuilderExtensions
      • HttpRequestExtensions
      • ILoggerExtensions
    • Code.Library.AspNetCore.Filters
      • TrackPerformanceFilter
    • Code.Library.AspNetCore.Helpers
      • SerilogHelper
    • Code.Library.AspNetCore.Middleware
      • ApiExceptionMiddleware
      • ApiExceptionMiddlewareExtensions
      • ApiExceptionOptions
      • RequestLoggingMiddlewareExtensions
    • Code.Library.AspNetCore.Middleware.RequestResponseLogging
      • ExcludeInRequestResponseLoggingOptions
      • IncludeInRequestResponseLoggingOptions
      • RequestResponseLoggingMiddleware
      • RequestResponseLoggingMiddlewareExtensions
      • RequestResponseLoggingOptions
    • Code.Library.Domain.Models
      • Enumeration
    • Code.Library.Dtos
      • AuditedEntityDto
      • AuditedEntityDto<TPrimaryKey>
      • CreationAuditedEntityDto
      • CreationAuditedEntityDto<TPrimaryKey>
      • EntityDto
      • EntityDto<TKey>
      • EntityRequestDto<TKey>
      • FullAuditedEntityDto
      • FullAuditedEntityDto<TPrimaryKey>
      • IEntityDto
      • IEntityDto<TKey>
      • IFullAuditedObject
      • IFullAuditedObject<TUser>
      • IHasTotalCount
      • ILimitedResultRequest
      • IListResult<T>
      • IPagedAndSortedResultRequest
      • IPagedResult<T>
      • IPagedResultRequest
      • ISortedResultRequest
      • LimitedResultRequestDto
      • ListResultDto<T>
      • PagedAndSortedResultRequestDto
      • PagedResultDto<T>
      • PagedResultRequestDto
    • Code.Library.Exceptions
      • DomainException
    • Code.Library.Extensions
      • DateTimeExtensions
      • FileSystemExtensions
      • GenericTypeExtensions
      • IEnumerableExtensions
      • NumberExtensions
      • ResultExtensions
      • StringExtensions
    • Code.Library.Helpers
      • DateTimeHelper
      • FileHelper
      • SerializationHelper
      • ThirdPartyHelper

    Class DateTimeExtensions

    All DateTime extensions.

    Inheritance
    object
    DateTimeExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Code.Library.Extensions
    Assembly: Code.Library.dll
    Syntax
    public static class DateTimeExtensions

    Methods

    | Improve this Doc View Source

    ConvertTo12H(TimeSpan)

    Convert timespan to 12H format string.

    Declaration
    public static string ConvertTo12H(this TimeSpan timeSpan)
    Parameters
    Type Name Description
    TimeSpan timeSpan

    Input timespan.

    Returns
    Type Description
    string

    Twelve hour format string.

    | Improve this Doc View Source

    DaysInMonth(DateTime)

    Returns the number of days in the month of specified date.

    Declaration
    public static int DaysInMonth(this DateTime value)
    Parameters
    Type Name Description
    DateTime value

    datetime.

    Returns
    Type Description
    int

    Number of days in the month of the specified date.

    | Improve this Doc View Source

    FirstDayOfMonth(DateTime)

    Returns the first day in the month of specified date.

    Declaration
    public static DateTime FirstDayOfMonth(this DateTime value)
    Parameters
    Type Name Description
    DateTime value

    Input date.

    Returns
    Type Description
    DateTime

    First date of the month of the specified date.

    | Improve this Doc View Source

    FirstDayOfYear(DateTime)

    Returns the first day in the year of the given date.

    Declaration
    public static DateTime FirstDayOfYear(this DateTime date)
    Parameters
    Type Name Description
    DateTime date

    The date.

    Returns
    Type Description
    DateTime

    The DateTime.

    | Improve this Doc View Source

    FromUnixTime(long)

    Converts unix time to datetime.

    Declaration
    public static DateTime FromUnixTime(this long value)
    Parameters
    Type Name Description
    long value

    unix value.

    Returns
    Type Description
    DateTime

    DateTime.

    | Improve this Doc View Source

    GetEachDay(DateTime, DateTime)

    Gives list of days between start and end date.

    Declaration
    public static IEnumerable<DateTime> GetEachDay(this DateTime startDate, DateTime endDate)
    Parameters
    Type Name Description
    DateTime startDate

    The start date.

    DateTime endDate

    The end date.

    Returns
    Type Description
    IEnumerable<DateTime>

    IEnumerable<T>.

    | Improve this Doc View Source

    Iso8601ToDateTime(string)

    Converts ISO 8601 time to datetime.

    Declaration
    public static DateTime Iso8601ToDateTime(this string iso8601text)
    Parameters
    Type Name Description
    string iso8601text

    ISO string.

    Returns
    Type Description
    DateTime

    DateTime.

    | Improve this Doc View Source

    LastDayOfMonth(DateTime)

    Returns the last day in the month of specified date.

    Declaration
    public static DateTime LastDayOfMonth(this DateTime value)
    Parameters
    Type Name Description
    DateTime value

    Input datetime.

    Returns
    Type Description
    DateTime

    last day as DateTime in the month of the specified date.

    | Improve this Doc View Source

    NameOfMonth(DateTime)

    Returns the name of month of the specified date.

    Declaration
    public static string NameOfMonth(this DateTime value)
    Parameters
    Type Name Description
    DateTime value

    Input datetime.

    Returns
    Type Description
    string

    Name of the month.

    | Improve this Doc View Source

    ToIso8601(DateTime)

    Returns the Iso 8601 format of the specified date.

    Declaration
    public static string ToIso8601(this DateTime date)
    Parameters
    Type Name Description
    DateTime date

    Input datetime.

    Returns
    Type Description
    string

    Iso8601 string for the specified datetime.

    | Improve this Doc View Source

    ToUnixTime(DateTime)

    Converts datetime value to unix time.

    Declaration
    public static long ToUnixTime(this DateTime value)
    Parameters
    Type Name Description
    DateTime value

    Input datetime.

    Returns
    Type Description
    long

    UnixTime.

    Exceptions
    Type Condition
    ArgumentException

    Specified value is lower than the UNIX time.

    • Improve this Doc
    • View Source
    In This Article
    • Methods
      • ConvertTo12H(TimeSpan)
      • DaysInMonth(DateTime)
      • FirstDayOfMonth(DateTime)
      • FirstDayOfYear(DateTime)
      • FromUnixTime(long)
      • GetEachDay(DateTime, DateTime)
      • Iso8601ToDateTime(string)
      • LastDayOfMonth(DateTime)
      • NameOfMonth(DateTime)
      • ToIso8601(DateTime)
      • ToUnixTime(DateTime)
    Back to top Generated by Abhith Rajan using DocFX