Normalizes DateTime values and handles time zones in ABP applications using IClock and ITimezoneProvider. Covers UTC policy, EF Core converters, and per-request timezone conversion.
Ships in abp-infrastructure. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use IClock instead of calling DateTime.Now or DateTime.UtcNow in application/domain code. AbpClockOptions.Kind defines the application's normalization policy; UTC is the only mode that enables multiple-timezone conversion.
DateTimeKind policy for an application.DateTime values.IClock.ITimezoneProvider.AbpClockOptions.Kind defaults to DateTimeKind.Unspecified. Configure UTC for applications that store instants and serve more than one timezone:
using Volo.Abp.Timing;
Configure<AbpClockOptions>(options =>
{
options.Kind = DateTimeKind.Utc;
});
The behavior is exact:
Configured Kind | IClock.Now | SupportsMultipleTimezone | Normalize behavior |
|---|---|---|---|
Utc | DateTime.UtcNow | true | Local converts with ToUniversalTime; Unspecified is relabeled UTC. |
Local | DateTime.Now | false | UTC converts with ToLocalTime; Unspecified is relabeled Local. |
Unspecified (default) | DateTime.Now | false | Returns the input unchanged. |
The default is intentionally permissive, but note the asymmetry: IClock.Kind reports Unspecified while IClock.Now comes from DateTime.Now. Do not infer that Clock.Now.Kind is unspecified.
public class BookingService : ITransientDependency
{
private readonly IClock _clock;
public BookingService(IClock clock)
{
_clock = clock;
}
public DateTime NormalizeStart(DateTime start)
{
return _clock.Normalize(start);
}
}
Normalize converts only a Local/UTC pair. When the input is Unspecified and the configured kind is Local or UTC, it uses DateTime.SpecifyKind; it does not apply a timezone offset. An unspecified browser wall-clock value therefore needs an explicit timezone conversion, not just Normalize.
IClock.ConvertToUserTime and ConvertToUtc operate only when the clock supports multiple timezones and ICurrentTimezoneProvider.TimeZone has a value.
var localDisplayTime = _clock.ConvertToUserTime(utcDateTime);
var utcInstant = _clock.ConvertToUtc(localWallClockTime);
ConvertToUserTime(DateTime) additionally requires an input whose kind is UTC.ConvertToUserTime(DateTimeOffset) preserves the instant and changes its offset.ConvertToUtc(DateTime) treats a non-UTC value as wall-clock time in the current timezone by first specifying Unspecified, then calling TimeZoneInfo.ConvertTimeToUtc.For a known timezone independent of the current request, use ITimezoneProvider:
var utc = _timezoneProvider.ConvertUnspecifiedToUtc( // ConvertUnspecifiedToUtc: ABP 10.6+
localWallClockTime,
"Europe/Berlin");
var timeZoneInfo = _timezoneProvider.GetTimeZoneInfo("Europe/Berlin");
ITimezoneProvider.ConvertUnspecifiedToUtc(...)is available from ABP 10.6+; on 10.5 convert withTimeZoneInfo/ConvertToUtcinstead.
ITimezoneProvider also exposes Windows/IANA lists and WindowsToIana / IanaToWindows. The default TZConvertTimezoneProvider delegates to TimeZoneConverter.
Add ABP's timezone middleware before endpoints, after authentication and tenant resolution when timezone settings depend on the current user/tenant:
app.UseAuthentication();
app.UseMultiTenancy();
app.UseAbpTimeZone();
app.UseAuthorization();
app.UseConfiguredEndpoints();
When UTC mode is enabled, AbpTimeZoneMiddleware selects a timezone in this order:
ISettingProvider value for Abp.Timing.TimeZone.__timezone request header, query string, form field, or cookie.It stores the selected value in ICurrentTimezoneProvider for the request through an AsyncLocal scope. If SupportsMultipleTimezone is false, it skips selection entirely.
AbpDbContext applies AbpDateTimeValueConverter / AbpNullableDateTimeValueConverter to writable DateTime and DateTime? properties. The converters call Clock.Normalize both when writing and reading.
Opt out only for a property/entity that intentionally preserves its original kind semantics:
[DisableDateTimeNormalization]
public DateTime ExternalWallClockTime { get; set; }
The attribute can be placed on the entity or property. ABP also skips this normalization setup for owned types and derived EF entity types. DateTimeOffset is not included in this automatic converter scan.
AuditPropertySetter uses Clock.Now for CreationTime, LastModificationTime, and DeletionTime. Changing AbpClockOptions.Kind therefore changes the kind policy used by automatic audit timestamps.
Tenant checks in the same setter protect creator/modifier/deleter user IDs when the entity tenant differs from the current user's tenant; they do not convert timestamps to a tenant-local value. Store audit instants under the global clock policy, then convert for display with the current timezone.
Clock.Kind, Clock.Now.Kind, and SupportsMultipleTimezone for the configured mode; do not treat them as interchangeable in Unspecified mode.Normalize with Utc, Local, and Unspecified inputs.ConvertToUtc / ConvertToUserTime.DateTime and nullable DateTime; verify their kinds and values. Verify an opted-out property is unchanged.IClock under the selected policy.DateTime.Now directly — it bypasses the configured clock and makes tests/persistence inconsistent.Normalize(Unspecified) converts from a user's timezone — it only relabels the kind. Use ConvertToUtc or ConvertUnspecifiedToUtc with a timezone.SupportsMultipleTimezone is true only for UTC mode.ConvertToUserTime at the presentation boundary.Clock.Now; timezone conversion belongs at input/output boundaries.[DisableDateTimeNormalization] broadly — it removes both read and write normalization for matching EF Core properties.What SKILL.md sets; muted values are Claude Code's defaults
/abp-infrastructure:handle-dates-and-timefrom abp-infrastructure
npx claudepluginhub abpframework/abp-skills --plugin abp-infrastructure16 skills in this plugin
/check-simple-stateComposable ABP simple-state conditions on definitions and UI state objects. USE FOR: ISimpleStateChecker, ISimpleStateCheckerManager, permission/feature/authentication conditions on IHasSimpleStateCheckers. DO NOT USE FOR: tenant/edition feature values (manage-settings-and-features); permission authorization of a service call (permissions-and-authorization); startup-time module capabilities (toggle-global-features)./configure-audit-loggingABP audit logging: per-request log of requests, actions, entity change history, exceptions. USE FOR: enabling/disabling auditing, GET request logging, entity change history, AuditLogContributors, ignoring types, [Audited]/[DisableAuditing], manual scopes with IAuditingManager. DO NOT USE FOR: general application/UI logging or Serilog (configure-logging); setting/feature values (manage-settings-and-features); background jobs/workers/handlers (background-jobs-and-events)./configure-loggingABP startup, runtime, exception logging, and the startup-template Serilog bridge. USE FOR: typed ILogger in ABP services; IInitLoggerFactory/GetInitLogger startup buffering; ABP exceptions via LogException; Serilog via UseSerilog. DO NOT USE FOR: audit-log persistence and entity history (configure-audit-logging); distributed traces and metrics (out of scope, wire the OpenTelemetry .NET SDK directly); exception-to-HTTP response details (handle-validation-and-errors).Other plugins' skills for the same job