Skip to content

ikelaiah/chronokit-fp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ“… ChronoKit-FP: Toolkit for Dates & Times in Free Pascal

License: MIT Free Pascal Lazarus Supports Windows Supports Linux Version No Dependencies Documentation Status

ChronoKit-FP is a lightweight toolkit designed to make date and time handling in Free Pascal easier for everyone. Whether you're calculating business days, handling timezones, or formatting dates, ChronoKit-FP offers practical tools to simplify your work.

// Get today's date and add 5 business days
var
  Today, NextWeek: TDateTime;
begin
  Today := TChronoKit.GetToday;
  NextWeek := TChronoKit.AddBusinessDays(Today, 5);
  WriteLn('Next workday: ', TChronoKit.GetAsString(NextWeek, 'yyyy-mm-dd'));
end;

🌟 Why ChronoKit-FP?

ChronoKit-FP is a cross-platform date and time library for Free Pascal developers. If you've ever struggled with timezone handling or needed better date manipulation tools, ChronoKit-FP has you covered. It gives you everything you need to work with dates, times, and timezones in your Free Pascal applications.

Key Features:

  • 🌍 Cross-Platform Timezone Support - Works on Windows and Linux
  • ⏰ 50+ DateTime Functions - Everything you need for date/time work
  • πŸ’Ό Business Day Calculations - Built-in workday calculations
  • 🎯 Simple API - Clean, easy-to-use function names
  • πŸ§ͺ Well Tested - 130+ tests ensure everything works
  • πŸ“š Good Documentation - Complete API reference with examples

πŸ“‘ Table of Contents

πŸ’» Installation (Lazarus IDE)

  1. Clone the repository:
git clone https://github.com/ikelaiah/chronokit-fp
  1. Open / start a new project in Lazarus IDE

  2. Go to Package β†’ Open Package File (.lpk)...

  3. Navigate to the ChronoKit packages in the packages/lazarus/ folder and select chronokit_fp.lpk

  4. In the package window that opens, click Compile

  5. Click Use β†’ Add to Project to install the package

The ChronoKit-FP package is now ready to use in your Lazarus project.

πŸ’» Installation (General)

  1. Clone the repository:
git clone https://github.com/ikelaiah/chronokit-fp
  1. Add the source directory to your project's search path.

πŸ“ Library Usage

uses
  // Date Time manipulation unit
  ChronoKit;          // Date Time operations

πŸš€ Quick Start

πŸ“… DateTime Operations

program ChronoKitDemo;
uses
  ChronoKit, SysUtils;

var
  CurrentTime, NextWorkday: TDateTime;
  TZInfo: TTimeZoneInfo;
  BusinessHours: TInterval;
  OffsetSign: string;
begin
  // Basic date/time operations
  CurrentTime := TChronoKit.GetNow;
  NextWorkday := TChronoKit.NextBusinessDay(CurrentTime);
  
  WriteLn('Current time: ', TChronoKit.GetAsString(CurrentTime, 'yyyy-mm-dd hh:nn:ss'));
  WriteLn('Next workday: ', TChronoKit.GetAsString(NextWorkday, 'yyyy-mm-dd'));
  
  // Business hours check (9 AM - 5 PM)
  BusinessHours := TChronoKit.CreateInterval(
    TChronoKit.StartOfDay(CurrentTime) + EncodeTime(9, 0, 0, 0),
    TChronoKit.StartOfDay(CurrentTime) + EncodeTime(17, 0, 0, 0)
  );
  
  if TChronoKit.IsWithinInterval(CurrentTime, BusinessHours) then
    WriteLn('βœ… Within business hours')
  else
    WriteLn('❌ Outside business hours');
    
  // Timezone information
  TZInfo := TChronoKit.GetTimeZone(CurrentTime);
  if TZInfo.Offset >= 0 then
    OffsetSign := '+'
  else
    OffsetSign := '-';
    
  WriteLn('Timezone: ', TZInfo.Name, ' (UTC', OffsetSign, IntToStr(Abs(TZInfo.Offset) div 60), ')');
  WriteLn('DST active: ', BoolToStr(TZInfo.IsDST, 'Yes', 'No'));
end.

Dependencies

  • Windows / Linux
    • No external dependencies required
  • Uses only standard Free Pascal RTL units

Build Requirements

  • Free Pascal Compiler (FPC) 3.2.2+
  • Lazarus 4.0+ (for compiling example projects and test suites)
  • Git for version control

πŸ“š Documentation

For detailed documentation, check out:

πŸ“Š Real-World Examples

You can use ChronoKit-FP to build all kinds of applications:

Example Project Description Source Code
ChronoKit Example Demonstrates the library's capabilities with practical use cases View Example
Add Business Days Calculate next business day, accounting for weekends and holidays View Example
Quick Start Demo Shows off what the library can do View Example

⚠️ Known Limitations

  • Platform Support: Currently works on Windows 11 and Ubuntu 24.04.
  • Timezone Database: Linux systems need timezone data installed (usually comes with most distributions).
  • DST Detection:
    • Windows: Has hardcoded US DST rules
    • Linux: Uses the system's timezone database
    • The library detects whether a given date/time falls within DST period

βœ… Testing

  1. Open the TestRunner.lpi using Lazarus IDE
  2. Compile the project
  3. Run the Test Runner:
cd tests
./TestRunner.exe -a --format=plain

🀝 Contributing

Want to help out? Great! Feel free to submit a Pull Request. For big changes, please open an issue first so we can chat about it.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

βš–οΈ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

About

ChronoKit-FP is a lightweight toolkit designed to make date and time handling in Free Pascal easier for everyone.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Languages