Process {{EPOCH}} template placeholder

This commit is contained in:
Matthias Gugel 2020-12-13 01:39:17 +01:00
parent d19f71926d
commit e6d25f4fa0
3 changed files with 15 additions and 1 deletions

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
filename_template

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/filename_template-merge.iml" filepath="$PROJECT_DIR$/.idea/filename_template-merge.iml" />
</modules>
</component>
</project>

View File

@ -24,9 +24,14 @@ class CreateFileWithFilenameTemplateAction(
IdeBundle.message("prompt.enter.new.file.name"), IdeBundle.message("prompt.enter.new.file.name"),
IdeBundle.message("title.new.file"), IdeBundle.message("title.new.file"),
null, null,
template, processTemplate(template),
validator validator
) )
return validator.createdElements return validator.createdElements
} }
private fun processTemplate(template: String): String {
val epoch = LocalDateTime.now(ZoneOffset.UTC).toEpochSecond(ZoneOffset.UTC)
return template.replace("{{EPOCH}}", epoch.toString())
}
} }