日本語 · English

shift — move by n units

Translated from the canonical Japanese page reference/shift.md. The source_sha above records the source revision; a consistency check flags this page when the Japanese original changes.

Category: point transform (body-layer core) / Signature: shift(n, unit: U) : Stream -> Stream / name settled (spec §5.4)

Meaning

Moves each point by n steps in unit U. Direction is carried by the sign; no direction words (back: and the like) are taken — once n becomes a variable, direction would be doubled across a word and a sign (ADR-21).

U is a premise-relative axis name with two faces:

Examples

3 business days before month-end (representative example §7.1. January: month-end 1/31 Sat → roll to 1/30 Fri → back 3 business days to 1/27 Tue):

# eval: 2026-01-01..2026-02-01
@JP
monthEnd |> roll(Preceding, on: bizDay) |> shift(-3, unit: bizDay)
#=> 2026-01-27
#~> 範囲外 2026-01-01..2026-01-02(holidays2026 covering 2026-01-01..2026-12-31, asof 2026-01-05)

Window units preserve the offset — Hachijūhachiya (87 days after the instant of Risshun, 2/4 05:02) moves with its time of day:

# eval: 2026-01-01..2026-06-01
@JP
sekki = [2026-01-05T17:23, 2026-01-20T10:45, 2026-02-04T05:02]
  covering: 2026..2026
  labels: [小寒, 大寒, 立春]
sekki |> filter(s => sekki(s) == 立春) |> shift(+87, unit: day)
#=> 2026-05-02T05:02
#~> 範囲外 2026-01-01..2026-03-29(sekki covering 2026-01-01..2026-12-31)

To land on a date, add snapTo(day) downstream.

Pitfalls

roll · snapTo · stride (thins rather than moves) · ADR-21.