Socket
Book a DemoInstallSign in
Socket

github.com/renatosaksanni/date-range-overlap

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/renatosaksanni/date-range-overlap

Source
Go
Version
v0.0.0-20240728043151-9061c54884fe
Version published
Created
Source

codecov Go Report Card

Date Range Overlap

This project provides a Go wrapper to check for overlapping date ranges. It utilizes a simple and efficient algorithm to determine if two date ranges overlap.

Summary of "The Overlapping Date Range Test"

The algorithm for determining if two date ranges overlap is as follows: Two periods overlap if the start date of one is before the end date of the other, and vice versa. This can be implemented in Go using the following condition:

if (period.End.After(selection.Start) && period.Start.Before(selection.End)) {
    // period overlaps selection
}

For more information, visit the original article: The Overlapping Date Range Test.

Setup

Prerequisites

  • Go 1.20 or higher

Install Dependencies

Clone the repository and run:

go mod tidy

Usage

Running the Main Program

To run the main program:

go run cmd/main.go

Running Tests

To run the unit tests:

go test ./... -coverprofile=coverage.out

FAQs

Package last updated on 28 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts