home / skills / christopheryeo / claude-skills / reverse-month

reverse-month skill

/reverse-month

This skill converts diverse date inputs into the reverse-month format YYYY-MM, enabling consistent monthly reporting and time-series analysis.

npx playbooks add skill christopheryeo/claude-skills --skill reverse-month

Review the files below or copy the command above to add this skill to your agents.

Files (2)
skill.md
2.7 KB
---
name: reverse-month
description: Convert dates from various formats to "reverse month" format (YYYY-MM), which is the ISO date format containing only the year and month components. Use when users need to extract year-month from dates, standardize month formats, or prepare dates for monthly aggregations and reporting.
---

# Reverse Month Converter

## Overview

Convert dates from various human-readable formats into standardized "reverse month" format (YYYY-MM). This skill handles flexible date input parsing and provides consistent, machine-readable month output by extracting only the year and month components from a full date.

The reverse month format is the year and month portion of an ISO date (YYYY-MM), making it ideal for monthly reporting, time-series aggregations, and calendar operations.

## Usage

Use the `convert_month.py` script to convert any date string to YYYY-MM format:

```bash
python scripts/convert_month.py "21 Oct 2025"
# Output: 2025-10
```

### Supported Input Formats

The script accepts a wide variety of date formats, including:

- **Month-day-year**: "21 Oct 2025", "October 21, 2025", "Oct 21, 2025"
- **Slash-separated**: "21/10/2025", "10/21/2025"
- **Dash-separated**: "21-10-2025", "2025-10-21"
- **ISO format**: "2025-10-21"
- **Other common formats**: Most standard date representations

### Examples

```bash
# Human-readable format
python scripts/convert_month.py "21 Oct 2025"
# → 2025-10

# Full month name
python scripts/convert_month.py "October 21, 2025"
# → 2025-10

# Slash format
python scripts/convert_month.py "21/10/2025"
# → 2025-10

# Already in ISO format
python scripts/convert_month.py "2025-10-21"
# → 2025-10

# Short format
python scripts/convert_month.py "Oct 2025"
# → 2025-10
```

### Error Handling

If the date string cannot be parsed, the script returns an error message:

```bash
python scripts/convert_month.py "invalid date"
# Error: Unable to parse date: 'invalid date'. Error: Unknown string format: invalid date
```

## Common Use Cases

- Monthly reporting and aggregations
- Calendar month filtering
- Time-series data grouping by month
- Standardizing month identifiers across different date formats
- Extracting billing or subscription periods

## Relationship to reverse-date Skill

This skill builds upon the reverse-date skill concept. While reverse-date converts dates to full ISO format (YYYY-MM-DD), reverse-month extracts only the year-month portion (YYYY-MM), providing a coarser granularity suitable for monthly operations.

## Implementation Details

The script uses Python's `dateutil.parser` library for flexible date parsing, which handles many common date formats automatically. The output is always in ISO 8601 year-month format (YYYY-MM).
```

Overview

This skill converts dates from many human-readable formats into the standardized reverse month format (YYYY-MM). It extracts only the year and month components so dates are ready for monthly reporting, aggregation, or filtering. The implementation uses Python and flexible parsing to accept a wide variety of input styles.

How this skill works

The tool parses an input date string with a tolerant parser and normalizes the result to the ISO year-month representation (YYYY-MM). It accepts full dates, partial dates (like 'Oct 2025'), slash/dash-separated forms, and typical human formats, returning an error if parsing fails. Internally it relies on date parsing libraries to interpret the input and then formats the datetime to year-month only.

When to use it

  • Preparing data for monthly aggregations or time-series grouping
  • Standardizing month identifiers across mixed source formats
  • Filtering or querying records by calendar month
  • Generating billing, subscription, or reporting periods
  • Converting user-entered dates to a consistent month key

Best practices

  • Prefer supplying a full date (day-month-year) when available to avoid ambiguity
  • Normalize input timezones or remove time components before parsing if timezone matters
  • Validate parsing success and handle errors by logging the original string
  • Use YYYY-MM output as a stable key in databases or filenames
  • Document expected input locales where ambiguous numeric dates (e.g., 03/04/2025) may vary

Example use cases

  • Transforming event timestamps into month keys for aggregation pipelines
  • Converting user-entered dates in forms to YYYY-MM for storage
  • Preparing monthly revenue reports by grouping transactions by YYYY-MM
  • Filtering calendar datasets to a target month using standardized strings
  • Creating filenames or directory structures that represent year-month slices

FAQ

What happens if the parser cannot interpret the input?

The skill returns a clear error indicating the string could not be parsed so you can log or handle the failure upstream.

Will it preserve timezone or day information?

No. The output intentionally contains only year and month; day and timezone are discarded after parsing.

Does it support inputs like 'Oct 2025' or '2025-10-21'?

Yes. It accepts full ISO dates, human-readable forms, and partial month-year formats and converts them to YYYY-MM.