Osk*_*lin 13
是的.
像这样的东西:
DateTime now = DateTime.now();
DateTime start = now;
DateTime stop = now.plusDays(10);
DateTime inter = start;
// Loop through each day in the span
while (inter.compareTo(stop) < 0) {
System.out.println(inter);
// Go to next
inter = inter.plusDays(1);
}
Run Code Online (Sandbox Code Playgroud)
另外,这是Clojure的clj-time的实现:
(defn date-interval
([start end] (date-interval start end []))
([start end interval]
(if (time/after? start end)
interval
(recur (time/plus start (time/days 1)) end (concat interval [start])))))
Run Code Online (Sandbox Code Playgroud)
这应该工作.
(take-while (fn [t] (cljt/before? t to)) (iterate (fn [t] (cljt/plus t period)) from))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5975 次 |
| 最近记录: |