shootismoke/common

View on GitHub
packages/ui/src/util/frequency.ts

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
// Sh**t! I Smoke
// Copyright (C) 2018-2021  Marcelo S. Coelho, Amaury M.

// Sh**t! I Smoke is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Sh**t! I Smoke is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Sh**t! I Smoke.  If not, see <http://www.gnu.org/licenses/>.

import type { Frequency } from './types';

/**
 * Convert a frequency to its equivalent period.
 *
 * @param frequency - The frequency to convert.
 */
export function frequencyToPeriod(frequency: Frequency): string {
    return frequency === 'daily'
        ? 'day'
        : frequency === 'weekly'
        ? 'week'
        : 'month';
}