time range expression in cron style

cronrange

GoDoc License GitHub Action Workflow Go Report Card Codacy Badge Codecov

cronrange is a Go package for time range expression in Cron style.

In a nutshell, CronRange expression is a combination of Cron expression and time duration to represent periodic time ranges, i.e. Cron for TimeRange. And it made easier to tell if the moment falls within the any time ranges (use IsWithin() method), and what's the next occurrence (use NextOccurrences() method).

For example, every New Year's Day in Tokyo can be written as:

DR=1440; TZ=Asia/Tokyo; 0 0 1 1 *

It consists of three parts separated by a semicolon:

  • DR=1440 stands for duration in minutes, 60 * 24 = 1440 min;
  • TZ=Asia/Tokyo is optional and for time zone using name in IANA Time Zone database;
  • 0 0 1 1 * is a cron expression representing the beginning of the time range.

Installation

To download the package:

go get -u github.com/1set/cronrange

Usage

To import it in your program as:

import "github.com/1set/cronrange"

Examples can be found in GoDoc.

License

FOSSA Status

Owner
A Set of Useful Libraries and Utilities
🛠
A Set of Useful Libraries and Utilities
Comments
  • Add license scan report and status

    Add license scan report and status

    Your FOSSA integration was successful! Attached in this PR is a badge and license report to track scan status in your README.

    Below are docs for integrating FOSSA license checks into your CI:

  • Schedules in github actions are disabled in forks by default

    Schedules in github actions are disabled in forks by default

    Scheduled github actions are diabled in forks on github by default. I believe that is correct as I don't want to enable it as it might mean that I get notifications every day about a build failure.

    image

    However as a result I don't get automated tests upon pushing it. Perhaps split the github action into 2: Scheduled: for integration components Test: For running on push and on pull request go test, coverage and lint actions?

  • Deepsource says CRT-A0004

    Deepsource says CRT-A0004

    Some deepsource fixes. I am not sure if s == "" is actually better than len(s) == 0 as we aren't dealing with C style strings but pascal-esq where the length is stored so can be easily referred to with an int comparison. But linter says so, so I must.

  • Use time.Duration & Allow custom cron.Parser

    Use time.Duration & Allow custom cron.Parser

    Hi, I have made some change to support some new features. The new methods ParseStringWithCronParser and Create allow users to pass their own cron.Parser, which someone may need an optional "seconds" field. And time.Duration is used for someone need second level accuration. The version is used to keep compatible, for the string representation may be different.

  • Added parser options: DefaultDuration

    Added parser options: DefaultDuration

    I've added a defautl duration as required for my usecase.

    It changes the signature to the Parse function but by using vargs it shouldn't impact any existing usage. I have extended the test cases to match too.

    A futher extension I would consider for my use-case is: DisableCustomDuration to force the default duration. (Or perhaps it would be "ForceDuration?")

    I haven't found a "great" way of doing opt args for options. This is typically how I do it. I have also seen people use it as an internal struct modifier ie:

    type Opts struct {
     defautlDuration *time.Duration
    }
    
    type ParserOpt interface {
      Apply(o *Opts) error
    }
    
    type DefaultDuration time.Duration
    
    func (dd DefaultDuration) Apply(o *Opts) error {
      var t time.Duration = time.Duration(dd)
      o.defaultDuration = &t
      return nil 
    }
    
    ...
    for _ opt := range opts { opt.apply(&opts) }
    ...
    
This package can parse date match expression, which used by ElasticSearch

datemath-parser this package is pure go package, this package can parse date match expression, which used by ElasticSearch. Date Math Definition you c

Jan 8, 2022
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.

Description pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. pflag is compatible with the GNU extensions to

Dec 30, 2022
Advanced ANSI style & color support for your terminal applications
Advanced ANSI style & color support for your terminal applications

termenv lets you safely use advanced styling options on the terminal. It gathers information about the terminal environment in terms of its ANSI & col

Dec 31, 2022
Style definitions for nice terminal layouts 👄
Style definitions for nice terminal layouts 👄

Lip Gloss Style definitions for nice terminal layouts. Built with TUIs in mind. Lip Gloss takes an expressive, declarative approach to terminal render

Dec 28, 2022
Pack a Go workflow/function as a Unix-style pipeline command
Pack a Go workflow/function as a Unix-style pipeline command

tpack Pack a Go workflow/function as a Unix-style pipeline command. Wiki In Unix-like computer operating systems, a pipeline is a mechanism for inter-

Nov 9, 2022
GitHub CLI extension to preview your markdown similar to the style of GitHub.
GitHub CLI extension to preview your markdown similar to the style of GitHub.

gh markdown-preview GitHub CLI extension to preview your markdown similar to the style of GitHub gh markdown-preview is a GitHub CLI extension to prev

Jan 8, 2023
Clirunner - Package clirunner runs a legacy shell-style CLI as if a human were running it.

clirunner Package clirunner runs a legacy shell-style command-line interpreter (CLI) as if a human were running it. A shell-style CLI offers a prompt

Jan 4, 2022
Simple, seamless, lightweight time tracking for Git
Simple, seamless, lightweight time tracking for Git

Git Time Metric Seamless time tracking for all your Git projects $ gtm report -last-month $ gtm report -last-month -format summary $ gtm report -last-

Dec 27, 2022
cTRL is a server for remote execution of pending tasks and commands in real time, supporting a queue with continuous thread limiting and throttling.

Документация на русском: https://github.com/eltaline/ctrl/blob/master/README-RUS.md cTRL is a server written in Go language that uses a modified versi

Mar 3, 2022
Simple time tracking CLI
Simple time tracking CLI

⏰ timetrace timetrace is a simple CLI for tracking your working time. Installation Homebrew brew tap dominikbraun/timetrace brew install timetrace Do

Jan 8, 2023
a work time management CLI tool for any platform
a work time management CLI tool for any platform

english |日本語 jobgosh | job management tool made with golang for shell a multi-platform work time management CLI tool to track and improve your day to

May 16, 2022
espnwrapper to track real time scores for your fav match... in a terminal while working.
espnwrapper to track real time scores for your fav match... in a terminal while working.

An espncricinfo wrapper written in go to track scores in real time and in the cmd/cli you can find the Command Line Interface wrapped over this wrapper.

Mar 13, 2022
A simple command line time description parser

Zeit Zeit is an extremely simple command line application to read a natural language time description and output it as a timestamp. The main usecase f

Aug 21, 2021
👀 A modern watch command. Time machine and pager etc.
👀 A modern watch command. Time machine and pager etc.

Viddy Modern watch command. Viddy well, gopher. Viddy well. Demo Features Basic features of original watch command. Execute command periodically, and

Jan 2, 2023
a simple golang program that shows the time in asci art.
a simple golang program that shows the time in asci art.

Curtime a simple golang program that shows the time in asci art. Installing Other For other distros you can grab a executable file from the releases.

Oct 8, 2021
This is a command line application to manage and fine-tune Time Machine exclude paths.

heptapod This is a command line application to manage and fine-tune Time Machine exclude paths. This repository is a WIP! The advertised functionality

Dec 28, 2022
A tiny cli command/daemon for syncing toggl time entries with Jira

toggl-sync A tiny cli command/daemon for syncing toggl time entries with Jira Installation Install the app via brew package manager. brew tap timemate

Nov 30, 2021
Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.
Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.

Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.

Aug 8, 2022
Go package and server app for retrieving time-stamped lyrics from Spotify.

lyricsapi Go package and server app for retrieving time-stamped lyrics from Spotify. Usage Use as package go get github.com/raitonoberu/lyricsapi pack

Nov 18, 2022