Skip to content

promo-manager: PromoInCurrentDay ignores dateNow/ctx.currentDate and is timezone-sensitive #220

Description

@vanilla-wave

Problem

export const PromoInCurrentDay = (date: Date) => {
    return () => date.toDateString() === new Date().toDateString();
};

Two issues:

  1. Ignores time injection. Every other helper uses ctx.currentDate (fed by options.dateNow); this one reads the real clock directly. Apps that inject server-synced time via dateNow (and tests with mocked time) get inconsistent behavior.
  2. Timezone shift. new Date('2024-06-01') parses as UTC midnight; toDateString() renders it in the local timezone. For users west of UTC that is May 31, so the promo shows on the wrong day (and does not show on the intended one).

Where

  • src/promo-manager/core/condition/condition-helpers.tsPromoInCurrentDay

Fix: compare against dayjs(ctx.currentDate) and compare calendar days explicitly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions