& Lt; abcframe & gt; time, abcframe time

Source: Internet
Author: User

<ABP framework> time, the time of the abp framework

Document directory

 

Content of this section:

  • Introduction
  • Clock
    • Client
  • Time Zone
    • Client
  • Binder and Converter

 

Introduction

Although some application target markets are only in one time zone, some application target markets are in many different time zones. In order to meet this requirement and centralize date operations in parallel, ABP provides a public basis for date operations.

 

Clock

Clock is the main object for cooperation with DateTime values. It defines the following static attributes/methods:

  • Now: Get the current time through the current supply.
  • Kind: Obtain the DateTimeKind of the current supply.
  • SupportsMultipleTimezone: gets a value that indicates whether the current supply supports multi-time zone applications.
  • Normalize: standardize/convert a given DateTime to fit the current supply.

Therefore, we use the DateTime. Now that abstracts Colok. Now to replace DateTime. Now:

DateTime now = Clock.Now;

The Clock is used internally in Clock. There are three built-in clock supplies:

  • ClockProviders. Unspecified (UnspecifiedClockProvider): the default clock provider, which acts like DateTime. Now. It eliminates the need for Clock classes.
  • ClockProviders. Utc (UtnClockProvideder): the UTC time is used, and Clock. Now is DateTime. UtcNow. The Normalize (Standardization) method converts a given time to utc time and sets its Kind (type) to DateTimeKind. Local.
  • ClockProviders. Local (LocalClockProvider): converts a specified time to a Local time using the Local time of the computer and sets its type to DateTimeKind. UTC. It supports multiple time zones.

You can set Clock. Provider to use a different Clock supply:

Clock.Provider = ClockProviders.Utc;

This is a common practice before an application starts (Application_Start in a Web application.

 

Client

When you set clock. Provider on the server side, the TTL. Clock. provider value is automatically set on the client side.

 

Time Zone

The ABP defines a configuration named "Abp. Timing. TimeZone" (the constant "TimingSettingNames. TimeZone") to store the selected host time zone. Assume that the value of the time zone is an available Windows Time Zone id. A Time Zone ing file is also defined to convert a Windows Time Zone to an IANA (Internet digital distribution organization) time zone, because some public libraries use the IANA Time Zone id. UtcClockProvider must be used to support multiple time zones. If UtcClockProvider is used, all date values are stored in UTC and sent to the client in UTC format, then, we can convert the UTC date to the user's time zone through the user's current time zone settings on the client.

 

Client

Create a Javascript Object named ABP. timing. timeZoneInfo, which contains time zone information for the current user. This information includes Windows and IANA Time Zone IDs and some additional windows Time Zone information. This information can be converted and displayed to the user's time zone.

 

Biner and Converter

  • In the MVC, Web Api, and Asp. new Core projects, the CEP automatically standardizes the received date according to the current clock supply.
  • When the EntityFramework or NHibernate module is used, the ABP automatically standardizes the date received from the database according to the current clock supply.

If the UTC clock is used, all the dates stored in the database are considered to be UTC values, and all the dates received from the client are considered to be UTC, except explicitly specified.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.