# `to_month()`
**Category:** Time and climatology
**Status:** stable

## Purpose
Provide the legacy monthly wrapper around `cube_aggregate_time()`.

## When to use
Use it when its declared input and output match the workflow. Prefer a narrower selection before any operation that may materialise values.

## When not to use
Do not use it to calculate `spatind` indicators or to bypass coordinate, CRS, unit, and provenance checks.

## Real signature
```r
to_month(x, fun = mean)
```

## Arguments
- `x`: see the installed Rd manual for validation and defaults.
- `fun`: see the installed Rd manual for validation and defaults.

## Input and output
Input: **ocean_cube**. Output: **ocean_cube**.

## Backend support
Memory: **TRUE**. NetCDF: **TRUE**. Mean, sum, min, max, and median use selective
period/block reads through `cube_aggregate_time()`. A deprecated arbitrary
`fun` may still materialise the complete cube.

## Dimensional effect
May change shape or return a non-cube analytical object; inspect dimensions/rows.

## Metadata
Units, spatial coordinates, provenance, masks, and temporal QA are retained.
The period table is lightweight; cell-level observation coverage is available
from the core with `diagnostics = TRUE`.

## Minimal executable check
```r
library(oceancube)
stopifnot(is.function(oceancube::to_month))
names(formals(oceancube::to_month))
```

## Example in a workflow
Typical position: `ocean_cube` → `to_month()` → `clim_month`. See the workflow scripts for a checked end-to-end example.

## Frequent errors and limitations
The wrapper preserves first-day Date output, including the historical
POSIXct-to-Date demotion, and warns for that exception. Arbitrary functions are
deprecated and use the legacy full-read path. Aggregation is observation
weighted, not duration weighted; use the core documentation for exact NA,
coverage, ISO-week, and season semantics.

## Related functions
Previous: `ocean_cube`. Next: `clim_month`.
