[ui, docs] add custom play time formatting

Signed-off-by: codeman4033 <codeman4033@eden-emu.dev>
This commit is contained in:
codeman4033 2026-03-23 15:12:55 -05:00
parent b673dad40d
commit af64395c6a
No known key found for this signature in database
GPG key ID: DE2F639DF2D265A3
13 changed files with 483 additions and 184 deletions

167
docs/user/CustomPlayTime.md Normal file
View file

@ -0,0 +1,167 @@
# Custom Play Time Syntax
This document describes the formatting syntax used to display custom playtime values in the emulator.
## Overview
Playtime is internally stored as a total number of seconds. This formatting system allows users to control how that value is displayed by using tokens inside a format string.
Example:
```
{H:02}:{M:02}:{S:02}
```
Output:
```
02:03:04
```
## Tokens
The following tokens can be used in format strings.
| Token | Description |
| ----- | ------------------------ |
| `{d}` | Total days |
| `{h}` | Total hours |
| `{H}` | Hours component (023) |
| `{m}` | Total minutes |
| `{M}` | Minutes component (059) |
| `{s}` | Total seconds |
| `{S}` | Seconds component (059) |
## Padding
Tokens may optionally include zero-padding using the syntax `:NN`, where `NN` is the minimum width.
Example:
```
{H:02}:{M:02}:{S:02}
```
This ensures each component is displayed with at least two digits.
Example output:
```
02:03:04
```
## Conditional Sections
Conditional sections allow parts of the format string to appear only when a specific time unit is non-zero. This is useful for hiding units such as `0h`.
Conditional sections use the following syntax:
```
[unit] ... [/unit]
```
Where `unit` is one of the following:
| Unit | Condition |
| ---- | ------------------------------ |
| `d` | Display section if days > 0 |
| `h` | Display section if hours > 0 |
| `m` | Display section if minutes > 0 |
Example:
```
[h]{H}h [/h][m]{M}m [/m]{S}s
```
Possible outputs:
```
1h 3m 4s
3m 4s
4s
```
Conditional sections may contain both tokens and literal text.
## Escaping Braces
To include literal braces in the output, they must be escaped using double braces.
| Input | Output |
| ----- | ------ |
| `{{` | `{` |
| `}}` | `}` |
Example:
```
Playtime: {{ {H}:{M}:{S} }}
```
Output:
```
Playtime: { 2:3:4 }
```
## Literal Text
Any text outside of tokens or conditional sections is copied directly into the output.
Example:
```
{h}h {M}m {S}s
```
Output:
```
26h 3m 4s
```
## Examples
### Clock Format
```
{H:02}:{M:02}:{S:02}
```
Example output:
```
02:03:04
```
### Human Readable Format
```
{h} hours, {M} minutes, {S} seconds
```
Example output:
```
26 hours, 3 minutes, 4 seconds
```
### Compact Format
```
[h]{H}h [/h][m]{M}m [/m][s]{S}s
```
Example output:
```
3m 4s
```
## Notes
* Playtime values are derived from the total number of elapsed seconds.
* Component tokens (`H`, `M`, `S`) wrap within their normal ranges.
* Total tokens (`h`, `m`, `s`) represent the full accumulated value for that unit.
* This is based on the [fmt syntax](https://fmt.dev/12.0/syntax/). Almost everything there is also supported here.

View file

@ -9,7 +9,7 @@ A copy of this handbook is [available online](https://git.eden-emu.dev/eden-emu/
## Basics
- **[The Basics](Basics.md)**
- **[Quickstart](./QuickStart.md)**
- **[Quickstart](QuickStart.md)**
- **[Settings](./Settings.md)**
- **[Controllers](./Controllers.md)**
- **[Controller profiles](./Controllers.md#configuring-controller-profiles)**
@ -26,6 +26,7 @@ A copy of this handbook is [available online](https://git.eden-emu.dev/eden-emu/
- **[Installing Atmosphere Mods](./InstallingAtmosphereMods.md)**
- **[Installing Updates & DLCs](./InstallingUpdatesDLC.md)**
- **[Alter Date & Time](./AlterDateTime.md)**
- **[Custom Play Time Syntax](./CustomPlayTime.md)**
## 3rd-party Integration