Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Exit strategie nejde parsovat v měsících, které nemají 31 dní #313

Closed
triceo opened this issue Sep 8, 2018 · 0 comments
Closed

Exit strategie nejde parsovat v měsících, které nemají 31 dní #313

triceo opened this issue Sep 8, 2018 · 0 comments

Comments

@triceo
Copy link
Member

triceo commented Sep 8, 2018

Předpokládejme strategii, která vyžaduje opuštění Zonky k 31. 12. 2021. Toto datum se překládá z textu do Javy následujícím kódem:

dateExpr returns [LocalDate result] :
d=intExpr DOT m=intExpr DOT y=intExpr
{
    $result = LocalDate.now()
        .withDayOfMonth($d.result)
        .withMonth($m.result)
        .withYear($y.result);
}

Bohužel se nejdříve nastavuje den v měsíci. Takže pokud je zrovna dnes září, tak po zavolání LocalDate.now().withDayOfMonth(31) vznikne neplatné datum (31. září) a vyhodí se výjimka s neplatnou strategií.

I takhle obskurní chyby se dají udělat...

@triceo triceo added this to the 4.8.0 milestone Sep 8, 2018
@triceo triceo closed this as completed in 4bbc61d Sep 8, 2018
triceo added a commit that referenced this issue Sep 8, 2018
The way we used before this commit could fail when the current month
didn't have 31 days.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant