Ported PlaceholderParser::update_timestamp() to XS

Note that Slic3r version number is now located in libslic3r.h
This commit is contained in:
Alessandro Ranellucci 2014-11-09 20:41:27 +01:00
parent 6135a9fb8b
commit 8b6a8e6307
7 changed files with 64 additions and 30 deletions

View file

@ -5,9 +5,9 @@ use warnings;
sub new {
# TODO: move this code to C++ constructor, remove this method
my ($class) = @_;
my $self = $class->_new;
$self->apply_env_variables;
$self->update_timestamp;
return $self;
}
@ -16,26 +16,6 @@ sub apply_env_variables {
$self->_single_set($_, $ENV{$_}) for grep /^SLIC3R_/, keys %ENV;
}
sub update_timestamp {
my ($self) = @_;
my @lt = localtime; $lt[5] += 1900; $lt[4] += 1;
$self->_single_set('timestamp', sprintf '%04d%02d%02d-%02d%02d%02d', @lt[5,4,3,2,1,0]);
$self->_single_set('year', "$lt[5]");
$self->_single_set('month', "$lt[4]");
$self->_single_set('day', "$lt[3]");
$self->_single_set('hour', "$lt[2]");
$self->_single_set('minute', "$lt[1]");
$self->_single_set('second', "$lt[0]");
$self->_single_set('version', $Slic3r::VERSION);
}
# TODO: or this could be an alias
sub set {
my ($self, $key, $val) = @_;
$self->_single_set($key, $val);
}
sub process {
my ($self, $string, $extra) = @_;