Convert UTC to MENA local time with Hijri seasons and Ramadan send rules

Go to Workflow
0 views
Built by Ibrahim Ibrahim
Created on August 06, 2026

Description

Quick overview
This sub-workflow takes a UTC timestamp and MENA locale inputs and returns a typed object with local time, workweek/weekend status, Hijri (Umm al-Qura) season flags, and Ramadan-aware sendability rules including a suggested next send time.

How it works
Receives inputs from another workflow (or a manual self-test) including ts_utc, tz, country, and audience.
Applies default values for missing inputs (for example Baghdad time zone, Iraq country code, and a current UTC timestamp).
Converts the UTC timestamp to the target IANA time zone, calculates the UTC offset, determines the local weekday, and flags workdays/weekends based on a per-country weekend table.
Computes the local day boundaries in UTC and the next workday start time to support rollups and scheduling.
Derives the Umm al-Qura Hijri date and flags Ramadan, Eid al-Fitr, Eid al-Adha, Hajj window, and any user-provided holiday overrides.
Classifies the local time into a daypart and evaluates whether the timestamp is inside an allowed send window (including Friday prayer blocking and Ramadan late-night rules), returning is_sendable, block_reason, and send_after when blocked.
Outputs either a self-test report with pass/fail assertions or a flattened “contract” object that downstream workflows can rely on.

Setup
In your parent workflow, add an Execute Workflow step that calls this sub-workflow and passes ts_utc (ISO 8601), tz (IANA time zone), country (for example iq, sa, ae, eg), and audience (b2c or b2b).
If you need to reflect local holiday announcements (for example Eid by moon sighting), pass holiday_overrides as an array of { date: "YYYY-MM-DD", country: "*"|"iq"|..., name: "..." }.
Optionally run the built-in manual self-test to validate weekend rules, day boundaries, and Ramadan send-window behavior in your environment.

Requirements
None. No credentials, no API keys, no npm packages, no external calls.

Customization
Every country defaults to a Fri-Sat weekend except ae, which is Sat-Sun. Edit the WEEKEND map. Pass holiday_overrides to correct Eid dates, since Umm al-Qura is astronomical while real announcements follow local moon sighting.

Nodes Used (1)

Code
n8n-nodes-base.code