public Function getInternalFormatFunction()

in src/main/java/com/epam/parso/date/SasTimeFormat.java [100:126]


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

                BigDecimal[] parts = new BigDecimal(sasSeconds).abs()
                        .setScale(precision, HALF_UP)
                        .divideAndRemainder(BIG_SECONDS_IN_MINUTE);

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