Skip to main content

Python package to decode day-of-week bitmasks

Project description

Bitmask decoder

Python wrapper to decode days-of-week bitmasks.

This mask is created by assigning an integer to each day of the week and summing up the integers of the relevant days.

It is assumed that the days are assigned as follows:

  • Monday: 1
  • Tuesday: 2
  • Wednesday: 4
  • Thursday: 8
  • Friday: 16
  • Saturday: 32
  • Sunday: 64

Any combinations of these days can be summed up to create a mask for that specific combination. For example:

42 = tuesday, thursday and saturday

Installation

bitmask-decoder is available via pip.

pip install -i https://test.pypi.org/simple/ bitmask-decoder==0.0.6

4 Functions

  • bitmask_decoder.decode_weekday()
  • bitmask_decoder.decode_all_weekdays()
  • bitmask_decoder.encode_weekday()
  • bitmask_decoder.encode_all_weekdays()

Example

import bitmask_decoder
bitmask_decoder.decode_weekday(17)                               
# ['Mon', 'Fri']

bitmask_decoder.decode_all_weekdays([9, 17, 127])                
# [['Mon', 'Thu'], ['Mon', 'Fri'], ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']]

bitmask_decoder.encode_weekday(["Monday", "Friday", "Saturday"]) 
# 49

bitmask_decoder.encode_all_weekdays([                            
    ["Monday", "Friday"],
    ["Friday", "Saturday", "Sunday"],
    ["Saturday", "Sunday"]
])
# [17, 112, 96]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitmask-decoder-0.0.7.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitmask_decoder-0.0.7-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file bitmask-decoder-0.0.7.tar.gz.

File metadata

  • Download URL: bitmask-decoder-0.0.7.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for bitmask-decoder-0.0.7.tar.gz
Algorithm Hash digest
SHA256 9143913448cd949b5d7cbf024bd903a7e5d183eade8b9fdb292928cf2eb465a9
MD5 2ed8124b8abde19ab67f5186843c8d58
BLAKE2b-256 5645237f2bc0ff84e2aa583148b0f6ff903aa12b6bd1ae6a57d134503fae07eb

See more details on using hashes here.

File details

Details for the file bitmask_decoder-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: bitmask_decoder-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for bitmask_decoder-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a3a19e0476f96b00c6453c9871ab76e846e5439666a092d57ba95e7d7738acdf
MD5 fe5f6e065eb7064fab542bc56f8e0fa5
BLAKE2b-256 0b54bf80d2c5d1214b292a45f24fe246010297b119daa565c9c9d24e3faa2de4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page