###
-# CNFDateTime objects provide conversions from script to high precision time function not inbuild into perl interpreter.
-# They are lightly initilized, compared to using DateTime directly, so this is not merely a wrapper around DateTime.
+# CNFDateTime objects provide conversions from script to high precision time function not inbuilt into perl interpreter.
+# They are lightly initialized, compared to using DateTime directly, so this is not merely a wrapper around DateTime.
#
package CNFDateTime;
use strict;
use constant{
FORMAT => '%Y-%m-%d %H:%M:%S',
+ FORMAT_SQUASH => '%Y%m%d%H%M%S',
FORMAT_Z => '%Y-%m-%d %H:%M:%S %Z',
FORMAT_NANO => '%Y-%m-%d %H:%M:%S.%3N %Z',
FORMAT_SCHLONG => '%A, %d %B %Y %H:%M:%S %Z',
FORMAT_MEDIUM => '%d %b %Y %H:%M:%S',
- DEFAULT_TIME_ZONE => 'UTC'
+ DEFAULT_TIME_ZONE => DateTime::TimeZone->new(name => 'local')->name()
};
# CNFDateTime instances begin with now, can be epoch zero that is $NULL, or _toCNFDate() parsed, they are never new.
elsif( $presume =~ /TZ|tz/){ $settings{TZ} = $r}
$settings{epoch} = time if not exists $settings{epoch};
$settings{TZ} = DEFAULT_TIME_ZONE if not defined $settings{TZ};
+ if(not DateTime::TimeZone->is_valid_name($settings{TZ})){
+ warn "Invalid TimeZone assigned: ". $settings{TZ};
+ $settings{TZ} = DEFAULT_TIME_ZONE;
+ warn "Reverting to system DEFAULT_TIME_ZONE: ". $settings{TZ};
+ }
return bless \%settings, $class
}
$self -> {timestamp} = $self->datetime() -> strftime(FORMAT_NANO);
return $self;
}
+sub toSquash($self){
+ $self -> {timestamp} = $self->datetime() -> strftime(FORMAT_SQUASH)
+}
sub _listAvailableCountryCodes(){
require DateTime::TimeZone;