public Function getInternalFormatFunction()

in src/main/java/com/epam/parso/date/SasTimeFormat.java [134:160]


        public Function<Double, String> getInternalFormatFunction(int width, int precision) {
            return (sasSeconds) -> {
                boolean negative = sasSeconds < 0;

                BigDecimal[] parts = new BigDecimal(sasSeconds).abs()
                        .divide(BIG_SECONDS_IN_MINUTE, precision, BigDecimal.ROUND_HALF_UP)
                        .divideAndRemainder(BIG_MINUTES_IN_HOUR);

                String hh = String.valueOf(parts[0].longValue());
                if (negative) {
                    hh = "-" + hh;
                }
                if (hh.length() > width) {
                    return "**";
                } else if (hh.length() > width - 3) {
                    return hh;
                } else {
                    String mm = parts[1].toString();
                    String hhmm = hh + (mm.length() > 1 && mm.charAt(1) != '.' ? ":" : ":0") + mm;
                    if (hhmm.length() > width) {
                        return hhmm.substring(0, width);
                    } else {
                        return hhmm;
                    }
                }
            };
        }