From 0f9cda3eb8afd89a9a2470d9a4c19a5c1c69b092 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 31 Aug 2024 12:24:59 +0200 Subject: streamline locale and timezone handling --- lib/Object/Groupware.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lib/Object/Groupware.pm (limited to 'lib/Object/Groupware.pm') diff --git a/lib/Object/Groupware.pm b/lib/Object/Groupware.pm new file mode 100644 index 0000000..083f415 --- /dev/null +++ b/lib/Object/Groupware.pm @@ -0,0 +1,37 @@ +use v5.36; +use Feature::Compat::Class 0.07; + +package Object::Groupware 0.01; + +class Object::Groupware; + +use utf8; + +use Log::Any qw( ); + +field $log = Log::Any->get_logger; + +field $dt_locale : param : reader = undef; +field $dt_time_zone : param : reader = undef; +field $dt_span_time_prefix : param : reader = ''; + +ADJUST { + if ( defined $self->dt_locale ) { + $dt_locale = DateTime::Locale->load( $self->dt_locale ) + unless $self->dt_locale isa DateTime::Locale::FromData; + $log->debugf( + 'Class %s set up to use locale %s (%s)', + __CLASS__, $self->dt_locale->code, $self->dt_locale->name + ); + } + if ( defined $self->dt_time_zone ) { + $dt_time_zone = DateTime::TimeZone->new( name => $self->dt_time_zone ) + unless $self->dt_time_zone isa DateTime::TimeZone; + $log->debugf( + 'Class %s set up to use time zone %s', + __CLASS__, $self->dt_time_zone->name + ); + } +} + +1; -- cgit v1.2.3