pax_global_header00006660000000000000000000000064137003100440014502gustar00rootroot0000000000000052 comment=36e16f8daca50abd4ccda394c9b111389c1b4280 ISO8601-0.13.0/000077500000000000000000000000001370031004400125345ustar00rootroot00000000000000ISO8601-0.13.0/.editorconfig000066400000000000000000000002421370031004400152070ustar00rootroot00000000000000root = true [*] indent_style = space indent_size = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [Makefile] indent_style = tab ISO8601-0.13.0/.gitignore000066400000000000000000000003071370031004400145240ustar00rootroot00000000000000# system crap .DS_Store .*.swp # development side effects .vagrant sandbox # files created by running the specs tmp # built gems pkg *.gem Gemfile.lock # documentation .yardoc doc bundle .bundle ISO8601-0.13.0/.rubocop.yml000066400000000000000000000010531370031004400150050ustar00rootroot00000000000000require: - rubocop-packaging AllCops: NewCops: enable Exclude: - bundle/vendors/**/* TargetRubyVersion: 2.4 Layout/LineLength: Max: 170 Lint/UselessComparison: Enabled: false Metrics/ClassLength: Max: 165 Metrics/MethodLength: Max: 24 Naming/MethodParameterName: Enabled: false Metrics/PerceivedComplexity: Max: 9 Style/Documentation: Enabled: false Style/NumericLiterals: MinDigits: 10 Style/NumericPredicate: Enabled: false Style/StringLiterals: Enabled: false Metrics/BlockLength: Exclude: - spec/**/* ISO8601-0.13.0/.travis.yml000066400000000000000000000001611370031004400146430ustar00rootroot00000000000000--- language: ruby before_install: gem install bundler -v 2.1.4 rvm: - 2.5.8 - 2.6.6 - 2.7.1 - ruby-head ISO8601-0.13.0/CHANGELOG.md000066400000000000000000000071541370031004400143540ustar00rootroot00000000000000## 0.13.0 * Fix RuboCop issues (thanks @utkarsh2102). * Change minimum required ruby version to 2.4 (thanks @utkarsh2102). ## 0.12.3 * Remove git dependency (thanks @utkarsh2102). ## 0.12.2 * Fix `DateTime#to_s` (thanks @nbeyer). ## 0.12.1 * Reduce the number of files that ship in the artifact (thanks @tas50). ## 0.12.0 * Fix `Months#to_seconds` from November (thanks @walterbrebels). ## 0.11.0 * Add support for unary minus operator (thanks @walterbrebels). ## 0.10.1 * Fix `TimeInterval` size for non UTC timezones. (#41) ## 0.10.0 * Fix `TimeInterval` with `/` patterns and leap years. * Fix decimal fractions on date atoms. **WARNING** some duration patterns are no longer valid. ## 0.9.1 * Fix `Duration#to_pattern` for negative durations based on a `Numeric` (thanks @figwit). ## 0.9.0 This version is **not compatible** with previous versions. Atoms and Durations changed their interface when treating base dates so it is only applied when computing the Atom length (e.g. `#to_seconds`). As a consequence, it is no longer possible to do operations like `DateTime + Duration`. * Add time intervals (thanks @Angelmmiguel). * Remove `Duration#to_i`. * Change `Duration#to_seconds` to accept a base `DateTime`. * Remove duration dependency on a base date on the instance level. * Change `Years#to_seconds` and `Months#to_seconds` to accept a base `DateTime`. * Remove atom dependency on a base date on the instance level. * Add `Atomic` mixin. * Remove `Atom` abstract class. * Allow `ISO8601::Duration` to perform operations with `Numeric` (thanks @Angelmmiguel). ## 0.8.7 * Make `Atom` comparable with the same kind (thanks @glassbead0). * Fix #18 document interfaces to core date/time classes. ## 0.8.6 * Fix #26 operations with Date, DateTime and Time with Duration (e.g. `ISO8601::DateTime.new('2012-07-07T20:20:20Z') - ISO8601::Duration.new('PT10M')`). * Fix #25 accept time components with timezone and only hour component (e.g. `ISO8601::Time.new('T10+01:00')`). * Fix Docker image for testing and inspecting. ## 0.8.5 * Fix `DateTime#hash` * Fix `DateTime#second` and `Time#second` precision. Now it's rounded to the first decimal. ## 0.8.4 * Remove unwanted log. ## 0.8.3 * Fix partial time patterns with timezone: `PThh:mmZ`, `PThhZ`. ## 0.8.2 * Fix time components using comma (,) as a decimal separator. ## 0.8.1 * Fix durations using comma (,) as a decimal separator. ## 0.8.0 * `DateTime` has hash identity by value. * `Time` has hash identity by value. * `Date` has hash identity by value. * `Duration` has hash identity by value. * `Atom` has hash identity by value. * `Atom#value` returns either an integer or a float. * `Atom#to_s` returns a valid ISO8601 subpattern. ## 0.7.0 * Add decimal fractions for any component in a duration. * Add a catch all `ISO8601::Errors::StandardError`. * Add support for comma (`,`) as a separator for duration decimal fractions. ## 0.6.0 * Add `#hash` to `Duration`, `Date`, `Time` and `DateTime`. ## 0.5.2 * Fix `DateTime` when handling empty strings. ## 0.5.1 * Fix durations with sign. ## 0.5.0 * Drop support for Ruby 1.8.7. * Add support for Rubinius 2. * `ISO8601::DateTime#century` no longer exists. Truncated representations were removed in ISO 8601:2004. * `ISO8601::DateTime#zone` delegates to core `DateTime#zone`. * `ISO8601::DateTime#timezone` no longer exists. Now it delegates to `DateTime#zone`. * A date can have sign: `-1000-01-01`, `+2014-05-06T10:11:12Z`. * A date time can be converted to an array of atoms with `#to_a`. * Ordinal dates supported. * A date component is represented by `ISO8601::Date`. * Week date pattern (YYYY-Wdww, YYYY-Www-D). ISO8601-0.13.0/CODE_OF_CONDUCT.md000066400000000000000000000044641370031004400153430ustar00rootroot00000000000000# Contributor Code of Conduct As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery * Personal attacks * Trolling or insulting/derogatory comments * Public or private harassment * Publishing other's private information, such as physical or electronic addresses, without explicit permission * Other unethical or unprofessional conduct Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer at asiches+iso8601@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident. This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at https://www.contributor-covenant.org/version/1/3/0/code-of-conduct.html [homepage]: https://www.contributor-covenant.org ISO8601-0.13.0/CONTRIBUTING.md000066400000000000000000000013541370031004400147700ustar00rootroot00000000000000# Contributing Thanks for taking the time to submit a pull request! These are the few guidelines to keep things coherent. [Fork the project](http://github.com/arnau/ISO8601/fork) and clone. Create your _feature_ branch: ```sh git checkout -b features/xyz ``` Set up your machine. I recommend using [Nix](https://nixos.org/nix/manual/): ```sh nix-shell ``` ```sh bundle install ``` Add your code and tests and check it passes: ```sh bundle exec rspec ``` Although not required, try to adhere to Rubocop's checks: ```sh bundle exec rubocop ``` Push your branch and submit a [Pull Request](https://github.com/arnau/iso8601/compare/). Add a description of your proposed changes and why they are needed. I'll review it as soon as I can. ISO8601-0.13.0/Gemfile000066400000000000000000000001051370031004400140230ustar00rootroot00000000000000# frozen_string_literal: true source 'http://rubygems.org' gemspec ISO8601-0.13.0/LICENSE000066400000000000000000000020631370031004400135420ustar00rootroot00000000000000Copyright (c) 2012-2020 Arnau Siches MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ISO8601-0.13.0/README.md000066400000000000000000000031271370031004400140160ustar00rootroot00000000000000# ISO8601 **[New maintainer wanted](https://github.com/arnau/ISO8601/issues/50)** Version 0.9.0 is **not compatible** with previous versions. Atoms and Durations changed their interface when treating base dates so it is only applied when computing the Atom length (e.g. `#to_seconds`). As a consequence, it is no longer possible to do operations like `DateTime + Duration`. Version 1.0.0 will lock public interfaces. Check the [changelog](https://github.com/arnau/ISO8601/blob/master/CHANGELOG.md) if you are upgrading from an older version. ISO8601 is a simple implementation of the ISO 8601 (Data elements and interchange formats — Information interchange — Representation of dates and times) standard. ## Build status [![Build Status](https://secure.travis-ci.org/arnau/ISO8601.png?branch=master)](http://travis-ci.org/arnau/ISO8601/) [![Gem Version](https://badge.fury.io/rb/iso8601.svg)](http://badge.fury.io/rb/iso8601) ## Supported versions * MRI 2.5, 2.6, 2.7 ## Documentation Check the [rubydoc documentation](http://www.rubydoc.info/gems/iso8601). Or take a look to the implementation notes: * [Date, Time, DateTime](docs/date-time.md) * [Duration](docs/duration.md) * [Time interval](docs/time-interval.md) ## Testing Install a Ruby version. E.g. you can install Ruby 2.7 with: ``` $ nix-shell ``` Then ``` $ bundle install $ bundle exec rake ``` ## Contributing [Contributors](https://github.com/arnau/ISO8601/graphs/contributors) Please see [CONTRIBUTING.md](./CONTRIBUTING.md) ## License Arnau Siches under the [MIT License](https://github.com/arnau/ISO8601/blob/master/LICENSE) ISO8601-0.13.0/Rakefile000066400000000000000000000003241370031004400142000ustar00rootroot00000000000000# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new task default: %i[ spec rubocop ] ISO8601-0.13.0/default.nix000066400000000000000000000012761370031004400147060ustar00rootroot00000000000000let pkgs = import {}; tooling = [ pkgs.exa pkgs.xsv pkgs.git pkgs.ruby_2_7 pkgs.rubyPackages_2_7.rake ]; in pkgs.mkShell { LANG = "en_GB.UTF-8"; EDITOR="vim"; buildInputs = tooling ++ [ ]; shellHook = '' set -o vi local pink='\e[1;35m' local yellow='\e[1;33m' local blue='\e[1;36m' local white='\e[0;37m' local reset='\e[0m' function git_branch { git rev-parse --abbrev-ref HEAD 2>/dev/null } export PS1="\[$pink\]nix \[$blue\]\W \[$yellow\]\$(git_branch)\[$white\] ∙ \[$reset\]" alias ls=exa source ${pkgs.git}/share/bash-completion/completions/git ''; } ISO8601-0.13.0/docs/000077500000000000000000000000001370031004400134645ustar00rootroot00000000000000ISO8601-0.13.0/docs/date-time.md000066400000000000000000000046001370031004400156570ustar00rootroot00000000000000# Date Time, Date, Time ## Interface with core classes ISO8601 classes provide a method `to_*` to convert to its core equivalent: ```ruby ISO8601::DateTime#to_datetime # => # ISO8601::Date#to_date # => # ISO8601::Time#to_time # => # ``` ## Differences with core Date, Time and DateTime ### Reduced precision Core `Date.parse` and `DateTime.parse` don't allow reduced precision. For example: ```ruby DateTime.parse('2014-05') # => ArgumentError: invalid date ``` But the standard covers this situation assuming any missing token as its lower value: ```ruby ISO8601::DateTime.new('2014-05').to_s # => "2014-05-01T00:00:00+00:00" ISO8601::DateTime.new('2014').to_s # => "2014-01-01T00:00:00+00:00" ``` The same assumption happens in core classes with `.new`: ```ruby DateTime.new(2014,5) # => # DateTime.new(2014) # => # ``` ### Unmatched precision Unmatched precison is handled strongly. Notice the time fragment is lost in `DateTime.parse` with no warning only if the loose precision is in the time component. ```ruby ISO8601::DateTime.new('2014-05-06T101112') # => ISO8601::Errors::UnknownPattern DateTime.parse('2014-05-06T101112') # => # ISO8601::DateTime.new('20140506T10:11:12') # => ISO8601::Errors::UnknownPattern DateTime.parse('20140506T10:11:12') # => # ``` ### Strong pattern matching Week dates raise an error when two digit days provied instead of return monday: ```ruby ISO8601::DateTime.new('2014-W15-02') # => ISO8601::Errors::UnknownPattern DateTime.new('2014-W15-02') # => # ``` ## Atomization `DateTime#to_a` allows decomposing to an array of atoms: ```ruby atoms = ISO8601::DateTime.new('2014-05-31T10:11:12Z').to_a # => [2014, 5, 31, 10, 11, 12, '+00:00'] dt = DateTime.new(*atoms) ``` ## Sign Ordinal dates keep the sign. `2014-001` is not the same as `-2014-001`. ## Fractional seconds precision Fractional seconds for `ISO8601::DateTime` and `ISO8601::Time` are rounded to one decimal. ```ruby ISO8601::DateTime.new('2015-02-03T10:11:12.12').second #=> 12.1 ISO8601::Time.new('T10:11:12.16').second #=> 12.2 ``` ISO8601-0.13.0/docs/duration.md000066400000000000000000000037271370031004400156440ustar00rootroot00000000000000# Duration > Durations are a component of time intervals and define the amount of > intervening time in a time interval. Source: [Wikipedia ISO8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) See [Time Interval](time-interval.md) for working with specific intervals of time. ## Supported patterns ``` PnYnMnDTnHnMnS PnW ``` `PT