From ab22a0c6bea13e7eb97079935f008168e0de1d38 Mon Sep 17 00:00:00 2001 From: Mateusz Czeladka Date: Fri, 24 Nov 2023 09:35:43 +0100 Subject: [PATCH] Fix: improved API. --- .../converters/EpochConversions.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/cardanofoundation/conversions/converters/EpochConversions.java b/src/main/java/org/cardanofoundation/conversions/converters/EpochConversions.java index 3c76384..b67b704 100644 --- a/src/main/java/org/cardanofoundation/conversions/converters/EpochConversions.java +++ b/src/main/java/org/cardanofoundation/conversions/converters/EpochConversions.java @@ -78,6 +78,26 @@ long epochToAbsoluteSlot(int epochNo) { return firstShelleySlot + absoluteSlotAssumingEra(Shelley, postByronEpochs); } + /** + * Converts epoch number to the UTC Time at the beginning of given epoch + * + * @param epochNo epoch number + * @return UTC time + */ + public LocalDateTime beginningOfEpochToUTCTime(int epochNo) { + return epochToUTCTime(epochNo, START); + } + + /** + * Converts epoch number to the UTC Time at the end of a given epoch + * + * @param epochNo epoch number + * @return UTC time + */ + public LocalDateTime endingOfEpochToUTCTime(int epochNo) { + return epochToUTCTime(epochNo, END); + } + /** * Converts epoch number to UTC time. * @@ -108,11 +128,6 @@ long absoluteSlotAssumingEra(Era era, int epochNo, EpochOffset epochOffset) { }; } - /** - * @param era - * @param epochNo - * @return - */ long absoluteSlotAssumingEra(Era era, int epochNo) { long allSlotsPerEra = genesisConfig.slotsPerEpoch(era) * epochNo; @@ -120,7 +135,7 @@ long absoluteSlotAssumingEra(Era era, int epochNo) { } /** - * Returns first slot of a given epoch. + * Returns first slot of a given epoch based on era. * * @param era - cardano era e.g. Byron, Shelley * @param epochNo - epoch number, e.g. 208 @@ -131,7 +146,7 @@ long firstEpochSlot(Era era, int epochNo) { } /** - * Returns last slot of a given epoch. + * Returns last slot of a given epoch based on era. * * @param era - cardano era e.g. Byron, Shelley * @param epochNo - epoch number, e.g. 208