<<ABP Frame >> Time

Source: Internet
Author: User
Tags time zones

Document Directory

The content of this section:

    • Brief introduction
    • Clock
      • Client
    • Time
      • Client
    • Binders and Converters

Brief introduction

While some application target markets are only in one time zone, some application target markets are many different time zones, to meet this demand and centralize date operations, ABP provides a public base for date operations.

Clock

Clock is the primary object that works with datetime values, and it defines the following static properties/methods:

    • Now: Gets the current time through the current provider.
    • Kind: Gets the datetimekind of the current provider.
    • Supportsmultipletimezone: Gets a value indicating whether the current provider can support a multi-zone app.
    • Normalize: Normalize/Convert a given datetime to fit the current supply.

So, we use abstract colok.now DateTime.Now instead of DateTime.Now:

Clock.now;

Clock supply is used internally in clock. There are three built-in clock providers:

    • Clockproviders.unspecified (Unspecifiedclockprovider): The default clock supply, behaves like DateTime.Now. It allows you to not use the clock class at all.
    • CLOCKPROVIDERS.UTC (Utnclockprovideder): In UTC time, Clock.now is Datetime.utcnow. The Normalize (normalized) method converts a given time into UTC time and sets its kind (kind) to datetimekind.local.
    • Clockproviders.local (Localclockprovider): With the local time of the computer, the Normailize method converts the given time to local time and sets its type to DATETIMEKIND.UTC. It supports multi-temporal zones.

You can set the Clock.provider to use a different clock supply:

CLOCKPROVIDERS.UTC;

This is the usual practice before the application starts (Application_Start in Web applications).

Client

The Abp.clock object in JavaScript uses the clock on the client, and when you set Clock.provider on the server, the ABP automatically sets the Abp.clock.provider value on the client.

Time

The ABP defines a named Abp.Timing.TimeZone setting (Timingsettingnames.timezone constant) to store the selected host time zone. The ABP assumes that the value of the time zone setting is an available Windows time zone ID. A time zone mapping file is also defined to convert a Windows time zone into the IANA (Internet Digital distribution Authority) time zone, because some public libraries use the IANA time zone ID. Utcclockprovider must be used to support multi-temporal zones. If you use Utcclockprovider, all date values are stored in UTC and sent to the client in UTC format, and then we can convert the UTC date to the user's time zone by setting the user's current time zone.

Client

ABP creates a JavaScript object, named Abp.timing.timeZoneInfo, that contains time zone information for the current user. This information contains the Windows and IANA time zone IDs and some additional Windows time zone information. This information can be converted and displayed to the user in the user's time zone.

Binders and Converters

    • In the MVC, Web API, and asp.new core projects, the ABP automatically standardizes the received date by the current clock supply.
    • When using the EntityFramework or NHibernate module, the ABP automatically standardizes the date received from the database according to the current clock supply.

If you use the UTC clock provider, all dates stored in the database are considered to be UTC values, and all dates received from the client are considered UTC, except as explicitly indicated.

<<ABP Frame >> Time

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.