Skip to main content

(YEARLY) MINUTE MAP

The idea is you can specify a value (int by default) for any and every minute of an entire year. Which particular year isn't representable.

Time specifiers are like cron but hierarchical. Hierarchy and priority matching rules are used to determine the value for any given minute of the year. A specification takes the form of a set of <expression, value> pairs in JSON or as a dictionary.

An expression is a dot-separated sequence of time tokens. The wildcard "*" may appear as a standalone spec or as a leaf segment, and means "everything else" not matched my siblings at this level.

Input may be a flat nested form; nested dicts are flattened by joining their key paths with ".". Both dict and JSON string are accepted.

The method YearMinuteMap.get_value() takes a datetime, and returns a value by selecting the most specific matching spec's value . Example:

my_minute_map =  {
  "*": 8,
  "h5-10": 28,
  "h19": {
    "*": 18,
    "m30-59": 22
  },
  "q2": {
    "h0-4": 10,
    "h5-10": 30,
    "h11-18": 10,
    "h19-23": 20,
  },
  "q3": {
    "h0-4": 12,
    "h5-10": 32,
    "h11-18": 12,
    "h19-23": 20,
    "sun": {
      "h0-4": 14,
      "h5-10": 34,
      "h11-18": 14,
      "h19-23": 23,
    }
  }
}
spec = YearMinuteMap(my_minute_map)
spec.get_value(my_date) # -> value

Flat Example:

  {
    "*": 1,
    "q1": 2,
    "q1.sun.h1-10.m1": 3
    "q1.sun.h1-10.m2": 4
  }

Crontab like steps and lists are also supported:

{
    "h0-11.m*/2": 1,
    "h12-23.m*/3": 2
}

EBNF for expression:

SPEC      ::= "*" | PATH
PATH      ::=
  ( QTR | ( "." ( DOM_PATH | DOW_PATH | HH_PATH | MM ) )? )
  | ( MOY | ( "." ( DOM_PATH | DOW_PATH | HH_PATH | MM ) )? )
  | WOY ( "." ( DOW_PATH | HH_PATH | MM ) )?
  | DOY ( "." ( HH_PATH | MM ) )?
  | DOM_PATH
  | DOW_PATH
  | HH_PATH
  | MM
DOM_PATH  ::= DOM ( "." ( HH_PATH | MM ) )?
DOW_PATH  ::= DOW ( "." ( HH_PATH | MM ) )?
HH_PATH   ::= HH ( "." MM )?
QTR       ::= "q1" | "q2" | "q3" | "q4" // Quarter (maps to moy range internally)
MOY       ::= "moy" RANGE      // Month of year    1-12   (aliases: jan…dec)
WOY       ::= "woy" RANGE      // ISO week         1-53
DOY       ::= "doy" RANGE      // Day of year      1-366
DOM       ::= "dom" RANGE      // Day of month     1-31
DOW       ::= "dow" RANGE      // Day of week      1-7    (aliases: mon…sun, 1=Mon)
HH        ::= "h" RANGE        // Hour             0-23
MM        ::= "m" RANGE        // Minute           0-59
RANGE     ::= ( ( DIGITS | DIGITS "-" DIGITS ) | "*" ) ("/" DIGITS) | ( DIGITS (,DIGITS)+ )

The grammar does not allow use of the same type of token twice (ex "dom12.dom13") or certain chaining (ex "q1.apr").

MOY and DOW have aliases MONTH and WEEKDAY not shown in EBNF:

MONTH     ::= "jan" | "feb" | "mar" | "apr" | "may" | "jun" |
              "jul" | "aug" | "sep" | "oct" | "nov" | "dec"
WEEKDAY   ::= "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun"

Tie breaking: Longer (more dots) paths beat shorter ones. The following order is used for tie breaks where path length is the same:

    QTR < MOY < DOW < DOM < WOY < DOY < HH < MM

Then specificity of the RANGE expression is used.

TODO: allow user to specify ordering by inputing a OrderDict or array.

Metadata

Release files for minutemap 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minutemap 0.2.1
File Size Uploaded
minutemap-0.2.1.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for minutemap 0.2.1
File Interpreter ABI Platform
minutemap-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / minutemap-0.2.1.tar.gz

Download URL minutemap-0.2.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
296dbc174c6bc05b47e3464cf6c48fd0dedceb0374fa84f0e0280dfc9edd347d
BLAKE2b-256 checksum
How to use checksums
15d1f6c685dacfda987f8389972d44dd1dc4cf9377b0115183fd0240d373dcf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / minutemap-0.2.1-py3-none-any.whl

Download URL minutemap-0.2.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f1de102d04fd391703171eda99219b92c0bfce8454290e0a64f9a1fff703ac2
BLAKE2b-256 checksum
How to use checksums
b500abf442ee6691d437f33f2eb25b1bb750028c1db5989f7d5e018504ef306a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page