date-threshold-arithmetic

date-threshold-arithmetic is a skill for Claude Code, Codex from fabioc-aloha/Alex_Skill_Mall. It costs 16 tokens per session (568 once invoked), scanned A, original, MIT.

A JavaScript pattern for counting complete days between dates before comparing them with a limit.

In plain words
What is it for?
Use it for “days since” checks, expiry rules, and scheduled tasks that depend on full days.
Why use it?
Millisecond differences can turn exactly seven days into a slightly larger decimal, causing a threshold check to trigger too early.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for “days since” checks, expiry rules, and scheduled tasks that depend on full days.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/fabioc-aloha/alex_skill_mall/date-threshold-arithmetic
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add fabioc-aloha/Alex_Skill_Mall --skill date-threshold-arithmetic
Clone the repo
git clone --depth 1 https://github.com/fabioc-aloha/Alex_Skill_Mall

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for date-threshold-arithmetic

README.md
[![agentmods](https://agentmods.dev/badge/skills/fabioc-aloha/alex_skill_mall/date-threshold-arithmetic.svg)](https://agentmods.dev/skills/fabioc-aloha/alex_skill_mall/date-threshold-arithmetic)
Your own site
<a href="https://agentmods.dev/skills/fabioc-aloha/alex_skill_mall/date-threshold-arithmetic"><img src="https://agentmods.dev/badge/skills/fabioc-aloha/alex_skill_mall/date-threshold-arithmetic.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 568 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00016 $0.00568
Opus 5 $0.00008 $0.00284
Sonnet 5 $0.00003 $0.00114
Haiku 4.5 $0.00002 $0.00057

Measured 4d ago against content hash d5e7c685dca8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

date-threshold-arithmetic scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/code-quality/date-threshold-arithmetic/skills/date-threshold-arithmetic/SKILL.md · 92 lines

What it actually says

Date Threshold Arithmetic

The Problem

Date comparisons at thresholds fail due to fractional days:

const daysBetween = (Date.now() - someDate.getTime()) / (1000 * 60 * 60 * 24);

// someDate is "exactly 7 days ago"
// daysBetween = 7.000012 (due to milliseconds)
// if (daysBetween > 7) { ... } // TRUE — unexpected!

The Solution

Always Math.floor() before threshold comparison.

function daysSince(date) {
  const ms = Date.now() - new Date(date).getTime();
  return Math.floor(ms / (1000 * 60 * 60 * 24));
}

// Now "exactly 7 days" = 7, not 7.000012
if (daysSince(lastCheck) > 7) {
  // Truly more than 7 full days
}

Common Traps

Code Bug
days > 7 Triggers on 7.0001
days >= 7 Doesn't trigger on 6.9999
days === 7 Never true for fractional values

Safe Patterns

// Days since (full days only)
const fullDays = Math.floor((now - then) / MS_PER_DAY);

// Is it past the threshold?
if (fullDays > threshold) { ... }

// Is it on or past the threshold?
if (fullDays >= threshold) { ... }

// Is it exactly N days?
if (fullDays === threshold) { ... }

For Cron-Style Checks

// "Run if last run was more than 24 hours ago"
const lastRun = new Date(stored.lastRunTime);
const hoursSince = (Date.now() - lastRun.getTime()) / (1000 * 60 * 60);

// Use Math.floor for "full hours"
if (Math.floor(hoursSince) >= 24) {
  runTask();
}

Verification

// Test edge case
const exactlySevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
console.log(daysSince(exactlySevenDaysAgo)); // Should be 7, not 7.xxx

When to Apply

  • Cache expiration checks
  • "Last N days" filters
  • Scheduled task triggers
  • Any date-based threshold

Tags

quality dates javascript bugs

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 92 lines · 16 tokens per session scan A d5e7c685dca8

Subscribe to this mod's changes

date-threshold-arithmetic is a skill published in the GitHub repository fabioc-aloha/Alex_Skill_Mall (4 stars, last pushed yesterday), licensed MIT. It adds 16 tokens to every session and 568 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.