<commit_before>package com.beolnix.marvin.im.plugin;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by beolnix on 11/9/2015.
 */
public class CountDownService {
    private final static int SECS_IN_MINUTE_FACTOR = 60;
    private final static int SECS_IN_HOUR_FACTOR = SECS_IN_MINUTE_FACTOR * 60;
    private final static int SECS_IN_DAY_FACTOR = SECS_IN_HOUR_FACTOR * 24;
    private HumanReadableDateUtils hrDateUtils = new HumanReadableDateUtils();


    public String getNewYearCountDown() {
        int year = LocalDateTime.now().getYear();

        LocalDateTime fromDateTime = LocalDateTime.now();
        LocalDateTime toDateTime = LocalDateTime.of(year, 12, 31, 23, 59, 59);

        return "до нового года осталось " + getHumanReadableCountDownTo(fromDateTime, toDateTime);
    }

    public String getMoneyCountDown() {
        int year = LocalDateTime.now().getYear();
        int month = LocalDateTime.now().getMonth().getValue();

        LocalDateTime fromDateTime = LocalDateTime.now();
        LocalDateTime toDate = LocalDateTime.of(year, month, 5, 19, 0, 1);

        return "до зарплаты осталось " + getHumanReadableCountDownTo(fromDateTime, toDate);
    }

    private String getHumanReadableCountDownTo(LocalDateTime fromDateTime, LocalDateTime toDateTime) {
        Duration duration = Duration.between(fromDateTime, toDateTime);
        long secondsTotal = duration.getSeconds();

        long days = howManyDaysIn(secondsTotal);
        long seconds_without_days = reduceSecondsOn(days, SECS_IN_DAY_FACTOR, secondsTotal);

        long hours = howManyHoursIn(seconds_without_days);
        long seconds_without_hours = reduceSecondsOn(hours, SECS_IN_HOUR_FACTOR, seconds_without_days);

        long minutes = howManyMinutesIn(seconds_without_hours);
        long seconds_without_minutes = reduceSecondsOn(minutes, SECS_IN_MINUTE_FACTOR, seconds_without_hours);

        long seconds = seconds_without_minutes;

        return prepareStringAnswer(days, hours, minutes, seconds);
    }

    private String prepareStringAnswer(long days, long hours, long minutes, long seconds) {
        LinkedList<String> answersList = new LinkedList<>();
        StringBuilder resultBuilder = new StringBuilder();
        int pastFactor = 1;
        String ending = ".";
        if ((days + hours + minutes + seconds) < 0) {
            resultBuilder.append("- уже прошло: ");<commit_msg>fix salary day month<commit_after>package com.beolnix.marvin.im.plugin;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by beolnix on 11/9/2015.
 */
public class CountDownService {
    private final static int SECS_IN_MINUTE_FACTOR = 60;
    private final static int SECS_IN_HOUR_FACTOR = SECS_IN_MINUTE_FACTOR * 60;
    private final static int SECS_IN_DAY_FACTOR = SECS_IN_HOUR_FACTOR * 24;

    private final static int SALARY_DAY_IN_MONTH = 5;

    private HumanReadableDateUtils hrDateUtils = new HumanReadableDateUtils();


    public String getNewYearCountDown() {
        int year = LocalDateTime.now().getYear();

        LocalDateTime fromDateTime = LocalDateTime.now();
        LocalDateTime toDateTime = LocalDateTime.of(year, 12, 31, 23, 59, 59);

        return "до нового года осталось " + getHumanReadableCountDownTo(fromDateTime, toDateTime);
    }

    public String getMoneyCountDown() {
        int year = LocalDateTime.now().getYear();
        int month = LocalDateTime.now().getMonth().getValue();

        LocalDateTime fromDateTime = LocalDateTime.now();

        if (fromDateTime.getDayOfMonth() > SALARY_DAY_IN_MONTH) {
            month += 1;
        }

        LocalDateTime toDate = LocalDateTime.of(year, month, 5, 19, 0, 1);

        return "до зарплаты осталось " + getHumanReadableCountDownTo(fromDateTime, toDate);
    }

    private String getHumanReadableCountDownTo(LocalDateTime fromDateTime, LocalDateTime toDateTime) {
        Duration duration = Duration.between(fromDateTime, toDateTime);
        long secondsTotal = duration.getSeconds();

        long days = howManyDaysIn(secondsTotal);
        long seconds_without_days = reduceSecondsOn(days, SECS_IN_DAY_FACTOR, secondsTotal);

        long hours = howManyHoursIn(seconds_without_days);
        long seconds_without_hours = reduceSecondsOn(hours, SECS_IN_HOUR_FACTOR, seconds_without_days);

        long minutes = howManyMinutesIn(seconds_without_hours);
        long seconds_without_minutes = reduceSecondsOn(minutes, SECS_IN_MINUTE_FACTOR, seconds_without_hours);

        long seconds = seconds_without_minutes;

        return prepareStringAnswer(days, hours, minutes, seconds);
    }

    private String prepareStringAnswer(long days, long hours, long minutes, long seconds) {
        LinkedList<String> answersList = new LinkedList<>();
        StringBuilder resultBuilder = new StringBuilder();
        int pastFactor = 1;
        String ending = ".";
        if ((days + hours + minutes + seconds) < 0) {
            resultBuilder.append("- уже прошло: ");
{'fraction_non_alphanumeric': 0.08728763913298183, 'fraction_numerical': 0.012107010349541106, 'mean_word_length': 3.7033976124885215, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3632858', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1440, 'n_words': 354}