forked from j62/ctbrec
Fix: date placeholders with patterns with more than one ocurrence are
This commit is contained in:
parent
dc8d288b05
commit
0e7b5b5452
|
@ -1,8 +1,13 @@
|
||||||
3.10.5
|
3.10.5
|
||||||
========================
|
========================
|
||||||
* You can now click on the recording / pause indicator to pause or resume
|
* MFC websocket now uses the TLS URL
|
||||||
recording in the thubmnail overview tabs
|
* Fix: date placeholders with patterns with more than one ocurrence are
|
||||||
|
replaced with the value of the first one
|
||||||
* Some smaller UI tweaks
|
* Some smaller UI tweaks
|
||||||
|
- adjusted component sizes for small resolutions
|
||||||
|
- recording indicator can now be used to pause / resume the recording
|
||||||
|
- adjusted scroll speed in the thumbnail overviews
|
||||||
|
- added shortcuts for the thumbnail overviews (keys 1-9 and arrow keys)
|
||||||
|
|
||||||
3.10.4
|
3.10.4
|
||||||
========================
|
========================
|
||||||
|
|
|
@ -67,15 +67,18 @@ public abstract class AbstractPlaceholderAwarePostProcessor extends AbstractPost
|
||||||
|
|
||||||
private String replaceDateTime(Recording rec, String filename, String placeHolder, ZoneId zone) {
|
private String replaceDateTime(Recording rec, String filename, String placeHolder, ZoneId zone) {
|
||||||
String pattern = "yyyy-MM-dd_HH-mm-ss";
|
String pattern = "yyyy-MM-dd_HH-mm-ss";
|
||||||
Matcher m = Pattern.compile("\\$\\{" + placeHolder + "(?:\\((.*?)\\))?\\}").matcher(filename);
|
Pattern regex = Pattern.compile("\\$\\{" + placeHolder + "(?:\\((.*?)\\))?\\}");
|
||||||
if (m.find()) {
|
Matcher m = regex.matcher(filename);
|
||||||
|
while (m.find()) {
|
||||||
String p = m.group(1);
|
String p = m.group(1);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
pattern = p;
|
pattern = p;
|
||||||
}
|
}
|
||||||
|
String formattedDate = getDateTime(rec, pattern, zone);
|
||||||
|
filename = m.replaceFirst(formattedDate);
|
||||||
|
m = regex.matcher(filename);
|
||||||
}
|
}
|
||||||
String formattedDate = getDateTime(rec, pattern, zone);
|
return filename;
|
||||||
return m.replaceAll(formattedDate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDateTime(Recording rec, String pattern, ZoneId zone) {
|
private String getDateTime(Recording rec, String pattern, ZoneId zone) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUtcTimeReplacement() {
|
public void testUtcTimeReplacement() {
|
||||||
|
// without user defined pattern
|
||||||
String date = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")
|
String date = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")
|
||||||
.withLocale(Locale.US)
|
.withLocale(Locale.US)
|
||||||
.withZone(ZoneOffset.UTC)
|
.withZone(ZoneOffset.UTC)
|
||||||
|
@ -61,12 +62,21 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
||||||
String input = "asdf_${utcDateTime}_asdf";
|
String input = "asdf_${utcDateTime}_asdf";
|
||||||
assertEquals("asdf_" + date + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, rec, config));
|
assertEquals("asdf_" + date + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, rec, config));
|
||||||
|
|
||||||
|
// with user defined pattern
|
||||||
date = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss")
|
date = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss")
|
||||||
.withLocale(Locale.US)
|
.withLocale(Locale.US)
|
||||||
.withZone(ZoneOffset.UTC)
|
.withZone(ZoneOffset.UTC)
|
||||||
.format(rec.getStartDate());
|
.format(rec.getStartDate());
|
||||||
input = "asdf_${utcDateTime(yyyyMMdd-HHmmss)}_asdf";
|
input = "asdf_${utcDateTime(yyyyMMdd-HHmmss)}_asdf";
|
||||||
assertEquals("asdf_" + date + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, rec, config));
|
assertEquals("asdf_" + date + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, rec, config));
|
||||||
|
|
||||||
|
// multiple occurences with user defined patterns
|
||||||
|
date = DateTimeFormatter.ofPattern("yyyy-MM-dd/yyyy")
|
||||||
|
.withLocale(Locale.US)
|
||||||
|
.withZone(ZoneOffset.UTC)
|
||||||
|
.format(rec.getStartDate());
|
||||||
|
input = "asdf_${utcDateTime(yyyy)}-${utcDateTime(MM)}-${utcDateTime(dd)}/${utcDateTime(yyyy)}_asdf";
|
||||||
|
assertEquals("asdf_" + date + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, rec, config));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue