Allow [version], [timestamp], [year], [month], [day], [hour], [minute], [second] in filenames. #318
This commit is contained in:
parent
49ff9a0ebe
commit
7ee08be0b8
2 changed files with 11 additions and 1 deletions
|
@ -679,6 +679,16 @@ sub replace_options {
|
|||
$string =~ s/\[($variables)\]/$more_variables->{$1}/eg;
|
||||
}
|
||||
|
||||
my @lt = localtime; $lt[5] += 1900; $lt[4] += 1;
|
||||
$string =~ s/\[timestamp\]/sprintf '%04d%02d%02d-%02d%02d%02d', @lt[5,4,3,2,1,0]/egx;
|
||||
$string =~ s/\[year\]/$lt[5]/eg;
|
||||
$string =~ s/\[month\]/$lt[4]/eg;
|
||||
$string =~ s/\[day\]/$lt[3]/eg;
|
||||
$string =~ s/\[hour\]/$lt[2]/eg;
|
||||
$string =~ s/\[minute\]/$lt[1]/eg;
|
||||
$string =~ s/\[second\]/$lt[0]/eg;
|
||||
$string =~ s/\[version\]/$Slic3r::VERSION/eg;
|
||||
|
||||
# build a regexp to match the available options
|
||||
my $options = join '|',
|
||||
grep !$Slic3r::Config::Options->{$_}{multiline},
|
||||
|
|
|
@ -377,7 +377,7 @@ sub write_gcode {
|
|||
|
||||
# write some information
|
||||
my @lt = localtime;
|
||||
printf $fh "; generated by Slic3r $Slic3r::VERSION on %02d-%02d-%02d at %02d:%02d:%02d\n\n",
|
||||
printf $fh "; generated by Slic3r $Slic3r::VERSION on %04d-%02d-%02d at %02d:%02d:%02d\n\n",
|
||||
$lt[5] + 1900, $lt[4]+1, $lt[3], $lt[2], $lt[1], $lt[0];
|
||||
|
||||
print $fh "; $_\n" foreach split /\R/, $Slic3r::notes;
|
||||
|
|
Loading…
Reference in a new issue