Alles gut, einen nützlichen Hinweis von zwei insgesamt ist ne gute Quote für ein Post kurz vorm Schlafgehen
Also Today.java
sieht jetzt insgesamt so aus:
package name.abuchen.portfolio.online.impl.variableurl.macros;
import java.time.LocalDate;
// ADDED LocalTime and ZoneOffset
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAmount;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import name.abuchen.portfolio.model.Security;
import name.abuchen.portfolio.online.impl.variableurl.VariableURLConstructor;
public class Today implements Macro
{
private static final Pattern MACRO = Pattern.compile("TODAY(:([^:]*)(:([PYMWDpymwd0123456789-]*))?)?"); //$NON-NLS-1$
private final DateTimeFormatter formatter;
private final TemporalAmount delta;
// ADDED the variable ut
private final boolean ut;
public Today(CharSequence input)
{
Matcher matcher = MACRO.matcher(input);
if (!matcher.matches())
throw new IllegalArgumentException();
String p = matcher.group(2);
// ADDED the definition of ut and changed the if condition
ut = (p.equals("unixtime")) ? true : false;
if (p == null || p.isEmpty() || ut)
formatter = DateTimeFormatter.ISO_DATE;
else
formatter = DateTimeFormatter.ofPattern(p);
String d = matcher.group(4);
if (d == null || d.isEmpty())
delta = Period.ZERO;
else
delta = Period.parse(d);
}
@Override
public VariableURLConstructor getVariableURLConstructor()
{
return null;
}
@Override
// MODIFIED the resolve method
public CharSequence resolve(Security security)
{
LocalDate ld = LocalDate.now().plus(delta);
if (ut == true)
return String.valueOf( ld.toEpochSecond(LocalTime.parse("00:00:00"), ZoneOffset.of("Z")));
else
return formatter.format(ld);
}
}
Hast du eine Ahnung wie ich das nun offiziell als Feature Vorschlag einreichen kann ohne einen github Account erstellen und mich da erst reinfuchsen zu müssen? Kenn mich auf github nämlich eher nur passiv aus.