Skip to content

feat!: Replace TimeSpan with FiniteDuration#2057

Open
farmdawgnation wants to merge 11 commits into
lift-5.0from
flint-latilla
Open

feat!: Replace TimeSpan with FiniteDuration#2057
farmdawgnation wants to merge 11 commits into
lift-5.0from
flint-latilla

Conversation

@farmdawgnation

Copy link
Copy Markdown
Member

This pull request refactors the Lift framework's time and scheduling utilities to use Scala's standard FiniteDuration instead of the custom TimeSpan type, removes deprecated and ambiguous time-related code, and simplifies duration formatting. It also updates the relevant tests and documentation to reflect these changes.

Key changes include:

Migration from TimeSpan to FiniteDuration

  • Replaced all usages of the custom TimeSpan type with Scala's FiniteDuration in scheduling APIs and internal implementations, including in Schedule, Wiring, and associated tests. This makes the codebase more idiomatic and less error-prone. [1] [2] [3] [4] [5] [6] [7]
  • Updated documentation and method signatures to reference FiniteDuration instead of TimeSpan. [1] [2]

Removal of Deprecated and Ambiguous Time Helpers

  • Removed the custom TimeSpan, TimeSpanBuilder, and related implicit conversions from TimeHelpers, along with the deprecated ConvertableToDate trait and its implicits. This eliminates sources of ambiguity and potential bugs. [1] [2]

Simplification and Modernization

  • Added a new, simpler formatDuration method for formatting durations as human-readable strings, replacing the old formatting logic.
  • Updated imports to remove references to the deleted time helpers and to use standard Scala duration types. [1] [2] [3] [4]
  • Cleaned up and clarified documentation throughout the affected files.

These changes modernize the codebase, reduce technical debt, and align the framework with standard Scala practices.

farmdawgnation and others added 11 commits June 23, 2026 21:47
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove TimeSpan, TimeSpanBuilder, related implicits, and ConvertableToDate from
TimeHelpers. Add formatDuration for human-readable duration strings. Tighten
Joda-Time import to only DateTime (still needed for DateTimeExtension).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ftSession

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…let, and related HTTP files

Fixes TimeSpan compilation errors across LiftRules.scala, LiftServlet.scala,
LiftMerge.scala, SessionMaster.scala, ResourceServer.scala, and
HttpAuthentication.scala. Duration-typed Long fields now use .toMillis,
and FactoryMaker types use FiniteDuration directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove all TimeSpan-based test blocks ("A TimeSpan" can/should, old
"Duration builders"), the TimeAmountsGen trait, and the Period/DateTime
joda imports. Add "Duration builder syntax" and "formatDuration" specs
using scala.concurrent.duration.FiniteDuration. Also fix ScheduleSpec
to use 10.millis instead of TimeSpan(10) now that Schedule.schedule
takes FiniteDuration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Updated Scaladoc on LAPinger.schedule to remove stale TimeSpan reference
(replaced with "delay milliseconds") and fixed an unclosed <code> HTML tag.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 26, 2026 01:19
@farmdawgnation farmdawgnation changed the title Flint latilla Replace TimeSpan with FiniteDuration Jun 26, 2026
@farmdawgnation farmdawgnation changed the title Replace TimeSpan with FiniteDuration feat!: Replace TimeSpan with FiniteDuration Jun 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes Lift’s time/scheduling utilities by removing the custom TimeSpan API surface and standardizing on Scala’s FiniteDuration (and explicit millisecond Longs where required), with associated updates across HTTP, Comet, JS command helpers, and tests.

Changes:

  • Replaced TimeSpan-based scheduling/duration APIs with FiniteDuration (and .toMillis conversions when interacting with millisecond Long APIs).
  • Removed deprecated/ambiguous time helper types and introduced a simplified formatDuration(millis: Long) utility.
  • Updated affected tests and call sites to use Scala duration DSL (10.millis, 30.seconds, etc.).

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/webkit/src/main/scala/net/liftweb/http/SessionMaster.scala Converts session cleanup threshold math to use FiniteDuration.toMillis.
web/webkit/src/main/scala/net/liftweb/http/ResourceServer.scala Updates cache header expiration calculations to use FiniteDuration.toMillis.
web/webkit/src/main/scala/net/liftweb/http/NamedCometActorTrait.scala Updates Comet actor lifespan signature to Box[FiniteDuration].
web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala Migrates various timeout/lifespan usages away from TimeSpan to FiniteDuration/millis.
web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala Updates scheduling and Comet timeout scheduling to match new duration/millis APIs.
web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala Changes LiftRules duration factories/vars to FiniteDuration or explicit millisecond Longs.
web/webkit/src/main/scala/net/liftweb/http/LiftMerge.scala Updates lazy snippet timeout arithmetic to use FiniteDuration.toMillis.
web/webkit/src/main/scala/net/liftweb/http/js/yui/YUIArtifacts.scala Updates JS artifacts fadeOut signature to FiniteDuration.
web/webkit/src/main/scala/net/liftweb/http/js/JsCommands.scala Migrates JS command timing types/serialization to FiniteDuration and toMillis.
web/webkit/src/main/scala/net/liftweb/http/js/JSArtifacts.scala Updates core JSArtifacts timing API to FiniteDuration.
web/webkit/src/main/scala/net/liftweb/http/js/jquery/JQueryArtifacts.scala Adapts JQuery artifacts to updated FiniteDuration JSArtifacts API.
web/webkit/src/main/scala/net/liftweb/http/js/jquery/JqJsCmds.scala Migrates jQuery JS commands from TimeSpan to FiniteDuration and toMillis.
web/webkit/src/main/scala/net/liftweb/http/js/extcore/ExtCoreArtifacts.scala Updates ExtCore artifacts fadeOut signature to FiniteDuration.
web/webkit/src/main/scala/net/liftweb/http/CometActor.scala Updates Comet lifespan type and lifespan timeout checks to use toMillis.
web/webkit/src/main/scala/net/liftweb/http/auth/HttpAuthentication.scala Makes nonce validity an explicit millisecond Long via toMillis.
web/webkit/src/main/scala/net/liftweb/builtin/comet/AsyncRenderComet.scala Updates lifespan signature to Box[FiniteDuration].
core/util/src/test/scala/net/liftweb/util/TimeHelpersSpec.scala Reworks tests to validate formatDuration and retained time helper functions.
core/util/src/test/scala/net/liftweb/util/ScheduleSpec.scala Updates scheduling tests to pass FiniteDuration delays (10.millis).
core/util/src/main/scala/net/liftweb/util/Wiring.scala Updates dependent notification scheduling to use FiniteDuration.
core/util/src/main/scala/net/liftweb/util/TimeHelpers.scala Removes TimeSpan implementation and adds formatDuration(millis: Long).
core/util/src/main/scala/net/liftweb/util/Schedule.scala Changes scheduler API to accept FiniteDuration and converts to millis for executor scheduling.
core/actor/src/main/scala/net/liftweb/actor/LAPinger.scala Updates documentation to reflect millisecond-based delay parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 102 to 104
* @return a <code>ScheduledFuture</code> which sends the <code>msg</code> to
* the <code>to<code> Actor after the specified TimeSpan <code>delay</code>.
* the <code>to<code> Actor after the specified FiniteDuration <code>delay</code>.
*/
Comment on lines 111 to 113
* @return a <code>ScheduledFuture</code> which sends the <code>msg</code> to
* the <code>to<code> Actor after the specified TimeSpan <code>delay</code>.
* the <code>to<code> Actor after the specified FiniteDuration <code>delay</code>.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants