Calendar Preferences
Configure timezone, week start, and date anchoring for accurate reporting
Overview
Calendar preferences control how timezone-sensitive operations work across Semaphor dashboards. They affect:
- Relative date filters such as "this week", "last month", and "year to date"
- Date aggregations like "group by week" or "group by month"
- Date formatting in visualizations and exports
By default, Semaphor uses UTC with Monday as the first day of the week. You can override these defaults at multiple levels to match your users' locale and reporting conventions.
Store Timestamps in UTC
Semaphor assumes that timestamps in your database are stored in UTC. When a tz preference is set, Semaphor converts from UTC to the target timezone for display, filtering, and aggregation. If your data is stored in a local timezone instead of UTC, date calculations may produce incorrect results.
Preference Hierarchy
Semaphor resolves calendar preferences using a multi-level hierarchy. The first level that defines a property wins, checked from top to bottom:
- Org User / Tenant User Preferences -- Individual org users and tenant users can set their own timezone and week start via the preferences dialog in the dashboard toolbar. These take the highest priority.
- Token Context -- Passed programmatically via
params.calendarContextin the token request. Use this when you, as the developer, want to set the default timezone and week start for your customers in embedded dashboards. - Tenant Defaults -- Defaults for all tenant users within a specific tenant, set by admins via the Management API.
- Organization Defaults -- Defaults for all org users and tenant users across the organization, set by admins via the Management API.
- System Default --
{ tz: 'UTC', weekStart: 1, anchor: 'now' }
Independent Resolution
Each property (tz, weekStart, anchor) is resolved independently. For example, if a tenant user has set their timezone but not their week start, the timezone comes from the tenant user's preferences while week start falls through to the next level that has it configured.
Resolution for Tenant Users
For a tenant user, Semaphor checks in this order:
- Tenant user's own preferences
- Token
calendarContext - Tenant defaults
- Organization defaults
- System default
Resolution for Org Users
For an org user, Semaphor checks in this order:
- Org user's own preferences
- Token
calendarContext - Organization defaults
- System default
Tenant defaults do not apply to org users since they are not associated with a specific tenant.
Setting Calendar Preferences
Via Token Request (Developer)
Pass calendarContext inside params when requesting an authentication token. This is the most common approach for embedded dashboards where your application already knows the user's timezone.
Security Note
The token generation function must be run on the server side. Do not expose
DASHBOARD_SECRET in client-side code in production.
Organization Defaults (Admin)
Set default calendar preferences for all org users and tenant users across the organization using the Management API:
Tenant Defaults (Admin)
Override organization defaults for all tenant users within a specific tenant:
Org User and Tenant User Preferences
Individual org users and tenant users can set their own preferences through the calendar preferences dialog in the dashboard toolbar. These preferences take the highest priority and override token, tenant, and organization defaults.
How It Affects Your Dashboard
Week Start and Relative Date Filters
The weekStart value determines how "this week" and other week-relative filters are calculated.
For the week containing January 8, 2025:
weekStart | "This Week" Range |
|---|---|
| 1 (Monday) | Mon Jan 6 -- Sun Jan 12 |
| 0 (Sunday) | Sun Jan 5 -- Sat Jan 11 |
This also affects "group by week" aggregations -- each bucket starts on the configured weekStart day.
Timezone and Date Boundaries
Timezone determines which calendar date a timestamp falls on. Consider a sale recorded at 11:00 PM EST on January 15:
tz | Displayed Date |
|---|---|
'UTC' | January 16 (4:00 AM UTC) |
'America/New_York' | January 15 (11:00 PM EST) |
Setting the correct timezone ensures records appear on the date your org users and tenant users expect.
Date Anchoring
By default, anchor is set to 'now', meaning relative date filters use the current time. For reproducible or historical views, pass a fixed ISO timestamp:
With this configuration, "last 7 days" always resolves relative to January 15, 2025 -- regardless of when the dashboard is viewed.
Calendar Context Properties
Calendar preferences are expressed as a calendarContext object with three properties:
| Property | Type | Default | Description |
|---|---|---|---|
tz | string | 'UTC' | IANA timezone identifier (e.g., 'America/Chicago', 'Europe/London') |
weekStart | 0-6 | 1 | First day of the week (0=Sunday, 1=Monday, ..., 6=Saturday) |
anchor | 'now' or { iso: string } | 'now' | Reference time for relative dates. Use a fixed ISO date for reproducible views. |
Common weekStart Values
| Value | Day | Regions |
|---|---|---|
| 0 | Sunday | US, Canada, Japan |
| 1 | Monday | ISO standard, Europe (default) |
| 6 | Saturday | Middle East |
Related
- Tokens API -- Full API reference for calendar context in token requests
- Filters -- How date filters work with calendar preferences
- Token Options -- All available options when generating embed tokens