private void Format_durations_init() { Xol_msg_mgr msg_mgr = lang.Msg_mgr(); int len = Xol_duration_itm_.Ary_default.length; interval_msgs = new Xol_msg_itm[len]; for (int i = 0; i < len; i++) { Xol_duration_itm itm = Xol_duration_itm_.Ary_default[i]; byte[] msg_key = Bry_.Add(Bry_duration, itm.Name_bry()); interval_msgs[i] = msg_mgr.Itm_by_key_or_new(msg_key); } }
public Xol_interval_itm[] Get_duration_intervals(long seconds, Xol_duration_itm[] intervals) { if (intervals == null) intervals = Xol_duration_itm_.Ary_default; Array_.Sort(intervals, Xol_duration_itm_sorter.Instance); int intervals_len = intervals.length; long val = seconds; List_adp rv = List_adp_.New(); for (int i = 0; i < intervals_len; i++) { Xol_duration_itm itm = intervals[i]; long itm_seconds = itm.Seconds(); val = seconds / itm_seconds; if (val > 0 || (i == intervals_len - 1 && rv.Count() == 0) // always add one seg; EX: 40 seconds, but minutes requested -> 0 minutes; // DATE:2014-05-10 ) { seconds -= val * itm_seconds; rv.Add(new Xol_interval_itm(itm, val)); } } return (Xol_interval_itm[]) rv.To_ary(Xol_interval_itm.class); }