// Path: datagen/src/main/java/io/qala/datagen/RandomShortApi.java
// public static <T> T sample(Collection<T> toSampleFrom) {
//     return from(toSampleFrom).sample();
// }


import java.time.*;
import java.time.chrono.ChronoLocalDateTime;
import java.time.chrono.ChronoZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import static io.qala.datagen.RandomShortApi.sample;
import static java.time.temporal.ChronoUnit.HOURS;
import static java.time.temporal.ChronoUnit.SECONDS;

    public static RandomDate plusMinus100Years() {
        return between(yearsAgo(100), inYears(100));
    }
    public Instant instant() {
        int MAX_NANO = 999_999_999;
        long minSecond = from.getEpochSecond();
        long maxSecond = to.getEpochSecond();
        long randomSeconds = RandomValue.between(minSecond, maxSecond).Long();
        int fromNano = from.getNano();
        int toNano = to.getNano();
        long nano = 0;
        if (minSecond == maxSecond) nano = RandomValue.between(fromNano, toNano).Long();
        else if (randomSeconds == maxSecond) nano = RandomValue.between(0, toNano).Long();
        else if (randomSeconds == minSecond) nano = RandomValue.between(fromNano, MAX_NANO).Long();

        return Instant.ofEpochSecond(randomSeconds, nano);
    }
    public List<Instant> instants(int n) {
        return multiply(n, this::instant);
    }

    public LocalDateTime localDateTime() {
        return LocalDateTime.ofInstant(instant(), ZoneId.systemDefault());
    }
    public List<LocalDateTime> localDateTimes(int nOfTimes) {
        return multiply(nOfTimes, this::localDateTime);
    }

    public ZonedDateTime zonedDateTime() {
// Path: datagen/src/main/java/io/qala/datagen/RandomShortApi.java
// public static <T> T sample(Collection<T> toSampleFrom) {
//     return from(toSampleFrom).sample();
// }


// Path: java8types/src/main/java/io/qala/datagen/RandomDate.java
import java.time.*;
import java.time.chrono.ChronoLocalDateTime;
import java.time.chrono.ChronoZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import static io.qala.datagen.RandomShortApi.sample;
import static java.time.temporal.ChronoUnit.HOURS;
import static java.time.temporal.ChronoUnit.SECONDS;


    public static RandomDate plusMinus100Years() {
        return between(yearsAgo(100), inYears(100));
    }
    public Instant instant() {
        int MAX_NANO = 999_999_999;
        long minSecond = from.getEpochSecond();
        long maxSecond = to.getEpochSecond();
        long randomSeconds = RandomValue.between(minSecond, maxSecond).Long();
        int fromNano = from.getNano();
        int toNano = to.getNano();
        long nano = 0;
        if (minSecond == maxSecond) nano = RandomValue.between(fromNano, toNano).Long();
        else if (randomSeconds == maxSecond) nano = RandomValue.between(0, toNano).Long();
        else if (randomSeconds == minSecond) nano = RandomValue.between(fromNano, MAX_NANO).Long();

        return Instant.ofEpochSecond(randomSeconds, nano);
    }
    public List<Instant> instants(int n) {
        return multiply(n, this::instant);
    }

    public LocalDateTime localDateTime() {
        return LocalDateTime.ofInstant(instant(), ZoneId.systemDefault());
    }
    public List<LocalDateTime> localDateTimes(int nOfTimes) {
        return multiply(nOfTimes, this::localDateTime);
    }

    public ZonedDateTime zonedDateTime() {
        return ZonedDateTime.ofInstant(instant(), ZoneId.of(sample(ZoneId.getAvailableZoneIds())));