From d52088565d6c3dc308d4a3c2062381a7e4c9e513 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Tue, 1 Apr 2025 17:14:40 +0000 Subject: [PATCH 1/2] Update timing.md --- docs/en/framework/infrastructure/timing.md | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/en/framework/infrastructure/timing.md b/docs/en/framework/infrastructure/timing.md index 7ddf1b730a..abcf0aa8f8 100644 --- a/docs/en/framework/infrastructure/timing.md +++ b/docs/en/framework/infrastructure/timing.md @@ -8,11 +8,11 @@ ABP provides a basic infrastructure to make it easy and handle automatically whe ## IClock -`DateTime.Now` returns a `DateTime` object with the **local date & time of the server**. A `DateTime` object **doesn't store the time zone information**. So, you can not know the **absolute date & time** stored in this object. You can only make **assumptions**, like assuming that it was created in UTC+05 time zone. The things especially gets complicated when you save this value to a database and read later, or send it to a client in a **different time zone**. +`DateTime.Now` returns a `DateTime` object with the **local date & time of the server**. A `DateTime` object **doesn't store the time zone information**. So, you can not know the **absolute date & time** stored in this object. You can only make **assumptions**, like assuming that it was created in UTC+05 time zone. Things especially get complicated when you save this value to a database and read it later, or send it to a client in a **different time zone**. -One solution to this problem is always use `DateTime.UtcNow` and assume all `DateTime` objects as UTC time. In this way, you can convert it to the time zone of the target client when needed. +One solution to this problem is always using `DateTime.UtcNow` and assuming all `DateTime` objects as UTC time. In this way, you can convert it to the time zone of the target client when needed. -`IClock` provides an abstraction while getting the current time, so you can control the kind of the date time (UTC or local) in a single point in your application. +`IClock` provides an abstraction while getting the current time, so you can control the kind of the datetime (UTC or local) in a single point in your application. **Example: Getting the current time** @@ -40,14 +40,14 @@ namespace AbpDemo } ```` -* Inject the `IClock` service when you need to get the current time. Common base classes (like ApplicationService) already injects it and provides as a base property - so, you can directly use as `Clock`. +* Inject the `IClock` service when you need to get the current time. Common base classes (like ApplicationService) already inject it and provide it as a base property - so, you can directly use it as `Clock`. * Use the `Now` property to get the current time. -> Most of the times, `IClock` is the only service you need to know and use in your application. +> Most of the time, `IClock` is the only service you need to know and use in your application. ### Clock Options -`AbpClockOptions` is the [options](../fundamentals/options.md) class that used to set the clock kind. +`AbpClockOptions` is the [options](../fundamentals/options.md) class that is used to set the clock kind. **Example: Use UTC Clock** @@ -58,13 +58,13 @@ Configure(options => }); ```` -Write this inside the `ConfigureServices` method of your [module](../architecture/modularity/basics.md). +Write this inside of the `ConfigureServices` method of your [module](../architecture/modularity/basics.md). -> Default `Kind` is `Unspecified`, that actually make the Clock as it doesn't exists at all. Either make it `Utc` or `Local` if you want to get benefit of the Clock system. +> The default `Kind` is `Unspecified`, which actually makes the **Clock** as it doesn't exist at all. Either make it `Utc` or `Local` if you want to get the benefit of the Clock system. ### DateTime Normalization -Other important function of the `IClock` is to normalize `DateTime` objects. +Another important function of the `IClock` is to normalize `DateTime` objects. **Example usage:** @@ -75,11 +75,11 @@ var normalizedDateTime = Clock.Normalize(dateTime) `Normalize` method works as described below: -* Converts the given `DateTime` to the UTC (by using the `DateTime.ToUniversalTime()` method) if current Clock is UTC and given `DateTime` is local. -* Converts the given `DateTime` to the local (by using the `DateTime.ToLocalTime()` method) if current Clock is local and given `DateTime` is UTC. +* Converts the given `DateTime` to the UTC (by using the `DateTime.ToUniversalTime()` method) if the current Clock is UTC and the given `DateTime` is local. +* Converts the given `DateTime` to the local (by using the `DateTime.ToLocalTime()` method) if the current Clock is local and the given `DateTime` is UTC. * Sets `Kind` of the given `DateTime` (using the `DateTime.SpecifyKind(...)` method) to the `Kind` of the current Clock if given `DateTime`'s `Kind` is `Unspecified`. -`Normalize` method is used by the ABP when the it gets a `DateTime` that is not created by `IClock.Now` and may not be compatible with the current Clock type. Examples; +`Normalize` method is used by the ABP when it gets a `DateTime` that is not created by `IClock.Now` and may not be compatible with the current Clock type. Examples; * `DateTime` type binding in the ASP.NET Core MVC model binding. * Saving data to and reading data from database via [Entity Framework Core](../data/entity-framework-core). @@ -94,7 +94,7 @@ var normalizedDateTime = Clock.Normalize(dateTime) In addition to the `Now`, `IClock` service has the following properties: * `Kind`: Returns a `DateTimeKind` for the currently used clock type (`DateTimeKind.Utc`, `DateTimeKind.Local` or `DateTimeKind.Unspecified`). -* `SupportsMultipleTimezone`: Returns `true` if currently used clock is UTC. +* `SupportsMultipleTimezone`: Returns `true` if the currently used clock is UTC. ## Time Zones @@ -108,6 +108,6 @@ See the [setting documentation](../infrastructure/settings.md) to learn more abo ### ITimezoneProvider -`ITimezoneProvider` is a service to simple convert [Windows Time Zone Id](https://support.microsoft.com/en-us/help/973627/microsoft-time-zone-index-values) values to [Iana Time Zone Name](https://www.iana.org/time-zones) values and vice verse. It also provides methods to get list of these time zones and get a `TimeZoneInfo` with a given name. +`ITimezoneProvider` is a service to simply convert [Windows Time Zone Id](https://support.microsoft.com/en-us/help/973627/microsoft-time-zone-index-values) values to [Iana Time Zone Name](https://www.iana.org/time-zones) values and vice verse. It also provides methods to get the list of these time zones and get a `TimeZoneInfo` with a given name. It has been implemented using the [TimeZoneConverter](https://github.com/mj1856/TimeZoneConverter) library. From 27a4f3c4ca964aa0515a2e31f0616ecd4c2f1ffe Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Tue, 1 Apr 2025 19:27:25 +0000 Subject: [PATCH 2/2] Update docs/en/framework/infrastructure/timing.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/en/framework/infrastructure/timing.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/en/framework/infrastructure/timing.md b/docs/en/framework/infrastructure/timing.md index abcf0aa8f8..be5569f863 100644 --- a/docs/en/framework/infrastructure/timing.md +++ b/docs/en/framework/infrastructure/timing.md @@ -60,8 +60,7 @@ Configure(options => Write this inside of the `ConfigureServices` method of your [module](../architecture/modularity/basics.md). -> The default `Kind` is `Unspecified`, which actually makes the **Clock** as it doesn't exist at all. Either make it `Utc` or `Local` if you want to get the benefit of the Clock system. - +> The default `Kind` is `Unspecified`, which effectively disables the **Clock** functionality. Either make it `Utc` or `Local` if you want to get the benefit of the Clock system. ### DateTime Normalization Another important function of the `IClock` is to normalize `DateTime` objects.