GithubHelp home page GithubHelp logo

hochfrequenz / mako_time_converter Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 0.0 114 KB

Go Package to Convert German "Gastag" to regular "Tag" and Inclusive↔Exclusive End Dates

License: MIT License

Go 100.00%
energiewirtschaft marktkommunikation

mako_time_converter's Introduction

mako_time_converter (go)

Unittest status badge Coverage status badge Linter status badge Go Reference

This is a Go module to convert between German "Gastag" and "Stromtag", between inclusive and exclusive end dates and combinations of all them. This is relevant for German Marktkommunikation ("MaKo").

This is a Golang port of the mako_datetime_converter for .NET.

Rationale

The German Marktkommunikation ("MaKo") defines some rules regarding date times:

  • you shall communicate end dates as exclusive (which is generally a good idea)
  • you shall use UTC date times with a specified UTC offset (which is a good idea)
  • and you shall always use UTC-offset 0 (a rule with good intentions)
  • in electricity all days (and contracts) start and end at midnight of German local time
  • but in gas all days (and contracts) start and end at 6am German local time ("Gas-Tag")

Now imagine there is an interface between two systems:

  • one of your systems obeys all of the above rules
  • but another one works differently (e.g. models end dates inclusively or is unaware of the differences between electricity and gas)

Then you need a conversion logic for your time.Times. This library does the conversion for you.

How To Use

See Go Playground for a minimal working example.

Note that this library only modifies timestamps, that are 06:00 German local time (if we're dealing with Gas) or 00:00 German local time (if we're not dealing with Gas). It won't shift arbitrary timestamps, so in most cases in your application you don't have to manually check if the conversion shall be applied to specific data constellations but only generally think about whether a time.Time is interpreted differently by different systems.

Code Quality / Production Readiness

  • The code has 95% unit test coverage. ✔️
  • The package has only one dependency itself (except for testing frameworks) ✔️:
  • The code has no linter warnings in the default golangci-lint configuration. ✔️

Implicit Requirements

The package requires your relevant timezone data to be present on the system on which you're using it. It does not include timezone data itself and will panic if the local timezone data is not found. Please import the time/tzdata package from the std library, if necessary.

The package does not include any workarounds to actual timezone data (e.g. in the case of Germany calculating the last Sunday in March or October.) You can do it but you probably shouldn't.

mako_time_converter's People

Contributors

deltadaniel avatar dependabot[bot] avatar hf-kklein avatar

Watchers

 avatar  avatar  avatar  avatar

mako_time_converter's Issues

Rationale clarification

The current "Rationale" section in README states:

and you shall always use UTC-offset 0 (which makes things unnecessary complicated)

Currently it reads like I shall use UTC offset 0 to make things unnecessary complicated, I guess that's not the intention.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.