# platform (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/platform/

Platform layer.
- Handles the window (or canvas), GL context, input events, frame loop and buffer swapping.
- The engine core (core::engine::EngineRunner) does not know the platform. Each platform exposes the following under the same names.
  run (engine runner), set_cursor_visible, set_cursor (cursor shape), is_coarse_pointer (whether the primary pointer is a finger), set_title, request_asset_bytes (reading asset bytes), PlatformWindow (the window handle the engine holds),
  write_clipboard_text / read_clipboard_text (system clipboard)
  read_page_query_value (a query value of the page URL), read_safe_area_insets (CSS env safe area insets)
  read_canvas_client_position (the top-left of the canvas in screen coordinates), read_client_native_size (the whole page size, None on desktop)
  save_capture_file (saving a screenshot for verification, a file on desktop, a download on the web)
- Only the web exposes is_gl_binding_present (whether something is bound in GL, because glow on the web panics when it reads null). (used by read_*_binding in core::graphic)
- Only macOS exposes vibrate_gamepads / release_disconnected_gamepad_haptics (gamepad vibration, desktop/gamepadhaptics.rs).
- Only desktop exposes desktop::read_heap_usage (heap usage of the system allocator, the memory field of the developer tools). (the web reads performance.memory as in the original)
- Android and iOS add modules here. (not yet)

## LocalTime (struct) (Clone, Copy, Debug, PartialEq, Eq)

Local time. (the calendar time in this machine's time zone, same as the {year, month, day, hour, minute, second, weekday} that the original Engine.readLocalTime returns)

Example: Read the current local time

```rust
use vanilla::platform::read_local_time;

let local_time = read_local_time(0.0);
assert!(local_time.year >= 2026);
assert!((1..=12).contains(&local_time.month));
assert!((1..=31).contains(&local_time.day));
assert!(local_time.hour < 24);
```

- `pub year: i32` (field, since 0.4.0): Year. (for example 2026)
  - returns i32
- `pub month: u32` (field, since 0.4.0): Month. (1 to 12)
  - returns u32
- `pub day: u32` (field, since 0.4.0): Day. (1 to 31)
  - returns u32
- `pub hour: u32` (field, since 0.4.0): Hour. (0 to 23)
  - returns u32
- `pub minute: u32` (field, since 0.4.0): Minute. (0 to 59)
  - returns u32
- `pub second: u32` (field, since 0.4.0): Second. (0 to 59)
  - returns u32
- `pub weekday: u32` (field, since 0.4.0): Weekday. (0 is Sunday, 6 is Saturday)
  - returns u32
