Skip to content
Partial implementation of ISO 8601 in Erlang
Erlang
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
MIT-LICENSE
README.markdown
iso_8601.erl
iso_8601_tests.erl

README.markdown

iso_8601_erl

Introduction

This project was started because I needed the ISO Week Number for a given date and I wanted it in Erlang. Since the calendar module in the stdlib-1.17.1 application of Erlang/OTP R14B did not provide this functionality, I decided to write it myself.

Rules

The following rules are used:

  • Week 01 is the week with the year's first Thursday in it.
  • Weeks start with Monday.
  • Monday is assigned the number 1.
  • Weeks ranges from 01 to 52 or 53 within a year.

Implementation

The module iso_8601.erl currently contains functions for computing the week number only. The standard covers far more than this. This module can be extended later, for now I needed only this.

The implementation is based on the calendar module of the stdlib application of Erlang/OTP.

The implementation was tested successfully with eunit using the tests file.

Examples

2010, 11, 19 -> "2010-W46-5"
2004, 12, 31 -> "2004-W53-5"
2000, 01, 01 -> "1999-W52-6"

Where the format "YYYY-Www-D" is used.

References

Something went wrong with that request. Please try again.