1k-date-formatting

Date and time formatting for OneKey applications. Use when displaying dates, timestamps, or formatting time in UI components. Always use OneKey utilities instead of native JS date methods. Triggers on date, time, timestamp, formatDate, formatTime, toLocaleDateString, toLocaleString, dateUtils, locale, format, display date, show time, datetime, calendar.

16 stars

Best use case

1k-date-formatting is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Date and time formatting for OneKey applications. Use when displaying dates, timestamps, or formatting time in UI components. Always use OneKey utilities instead of native JS date methods. Triggers on date, time, timestamp, formatDate, formatTime, toLocaleDateString, toLocaleString, dateUtils, locale, format, display date, show time, datetime, calendar.

Teams using 1k-date-formatting should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/1k-date-formatting/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/1k-date-formatting/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/1k-date-formatting/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How 1k-date-formatting Compares

Feature / Agent1k-date-formattingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Date and time formatting for OneKey applications. Use when displaying dates, timestamps, or formatting time in UI components. Always use OneKey utilities instead of native JS date methods. Triggers on date, time, timestamp, formatDate, formatTime, toLocaleDateString, toLocaleString, dateUtils, locale, format, display date, show time, datetime, calendar.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Date Formatting

Guidelines for consistent date and time formatting across OneKey applications.

## Critical Rule

**NEVER use native JavaScript date methods:**
```typescript
// ❌ FORBIDDEN
date.toLocaleDateString()
date.toLocaleString()
date.toISOString()
new Intl.DateTimeFormat().format(date)

// ✅ CORRECT
import { formatDate } from '@onekeyhq/shared/src/utils/dateUtils';
formatDate(date, { hideSeconds: true });
```

## Quick Reference

| Function | Use Case | Example Output |
|----------|----------|----------------|
| `formatDate(date, options?)` | Full date and time | `2024/01/15, 14:30` |
| `formatTime(date, options?)` | Time only | `14:30:45` |
| `formatRelativeDate(date)` | Relative display | `Today`, `Yesterday` |
| `formatDistanceToNow(date)` | Time distance | `2 hours ago` |
| `formatDateFns(date, format?)` | Custom format | Based on template |

## Common Patterns

### Transaction History
```typescript
import { formatDate } from '@onekeyhq/shared/src/utils/dateUtils';

// Hide year if current year, hide seconds
<SizableText>
  {formatDate(item.createdAt, { hideTheYear: true, hideSeconds: true })}
</SizableText>
```

### Custom Format
```typescript
// Use format template
{formatDate(item.timestamp, { formatTemplate: 'yyyy-LL-dd HH:mm' })}
```

### React Hook (for dynamic updates)
```typescript
import useFormatDate from '@onekeyhq/kit/src/hooks/useFormatDate';

function MyComponent() {
  const { formatDate } = useFormatDate();
  return <SizableText>{formatDate(date, { hideSeconds: true })}</SizableText>;
}
```

## Format Options

```typescript
interface IFormatDateOptions {
  hideYear?: boolean;        // Always hide year
  hideMonth?: boolean;       // Always hide month
  hideTheYear?: boolean;     // Hide year if current year
  hideTheMonth?: boolean;    // Hide month if current month
  hideTimeForever?: boolean; // Hide time portion
  hideSeconds?: boolean;     // Hide seconds (HH:mm)
  formatTemplate?: string;   // Custom date-fns format
}
```

## Detailed Guide

For comprehensive date formatting rules and examples, see [date-formatting.md](references/rules/date-formatting.md).

Topics covered:
- Core utilities from `@onekeyhq/shared/src/utils/dateUtils`
- Available formatting functions
- Options reference and format templates
- Common patterns for transactions, history, and relative time
- React hooks for dynamic updates
- Locale-aware formatting
- Real-world examples
- Troubleshooting

## Key Files

| Purpose | File Path |
|---------|-----------|
| Core utilities | `packages/shared/src/utils/dateUtils.ts` |
| React hook | `packages/kit/src/hooks/useFormatDate.ts` |
| Locale mapping | `packages/shared/src/locale/dateLocaleMap.ts` |

## Related Skills

- `/1k-i18n` - Internationalization and locale handling
- `/1k-coding-patterns` - General coding patterns

Related Skills

61-validate-lint-150

16
from diegosouzapw/awesome-omni-skill

[61] VALIDATE. Comprehensive code quality check combining ESLint, TypeScript compilation, and unused code detection. Runs full lint suite with detailed error reporting and fix suggestions. Use before commits, after major changes, or when ensuring code quality standards.

asyncredux-optimistic-update-mixin

16
from diegosouzapw/awesome-omni-skill

Add the OptimisticUpdate mixin for instant UI feedback before server confirmation. Covers immediate state changes, automatic rollback on failure, and optionally notifying users of rollback.

validate-historical

16
from diegosouzapw/awesome-omni-skill

Validate historical data completeness and quality over date ranges

update-screenshots

16
from diegosouzapw/awesome-omni-skill

Download screenshot baselines from the latest CI run and commit them. Use when asked to update, accept, or refresh component screenshot baselines from CI, or after the screenshot-test GitHub Action reports differences. This skill should be run as a subagent.

update-llm-model-list

16
from diegosouzapw/awesome-omni-skill

Audit and update the supported LLM model list in assets.py against litellm's registry (models.litellm.ai). Use when adding new models, pruning outdated ones, or verifying the list is correct.

update-instruction

16
from diegosouzapw/awesome-omni-skill

Create, update, or manage universal-ai-config instruction templates. Handles finding existing instructions, deciding whether to create or modify, and writing the template.

update-google-agent-models

16
from diegosouzapw/awesome-omni-skill

Fast-path Google/Gemini-only agent chain update. Use when user says "Update Gemini Agent Models", "Update Gemnini Agent Models", or "Update Google Agent Models".

bulk-cms-update

16
from diegosouzapw/awesome-omni-skill

Create or update multiple CMS items in a Webflow collection with validation and diff preview. Use when adding multiple blog posts, products, or updating fields across many items.

updatekfg

16
from diegosouzapw/awesome-omni-skill

Synchronizacja KFG między urządzeniami (Windows/Android). Triggers: sync KFG, updatekfg, zaktualizuj

date-validation

16
from diegosouzapw/awesome-omni-skill

Use when editing Planning Hubs, timelines, calendars, or any file with day-name + date combinations (Wed Nov 12), relative dates (tomorrow), or countdowns (18 days until) - validates day-of-week accuracy, relative date calculations, and countdown math with two-source ground truth verification before allowing edits

apps-script-update

16
from diegosouzapw/awesome-omni-skill

Google Apps Script のコードを更新する。「GAS 更新」「Apps Script 更新」「スクリプト編集」「コードを更新」などで起動。

Validate with Database

16
from diegosouzapw/awesome-omni-skill

Connect to live PostgreSQL database to validate schema assumptions, compare pg_dump vs pgschema output, and query system catalogs interactively