pax_global_header00006660000000000000000000000064133643611240014515gustar00rootroot0000000000000052 comment=ecbca77eb78de1a813c723da0b881627d8eedfe6 ISO8601-0.12.1/000077500000000000000000000000001336436112400125475ustar00rootroot00000000000000ISO8601-0.12.1/.circleci/000077500000000000000000000000001336436112400144025ustar00rootroot00000000000000ISO8601-0.12.1/.circleci/config.yml000066400000000000000000000013061336436112400163720ustar00rootroot00000000000000version: 2 jobs: build: working_directory: ~/iso8601 docker: - image: circleci/ruby:2.4.1 environment: TESTOPTS: "--ci-dir=/tmp/test-results" steps: - checkout # Restore bundle cache - type: cache-restore key: iso8601-{{ checksum "Gemfile.lock" }} # Bundle install dependencies - run: bundle install --path vendor/bundle # Store bundle cache - type: cache-save key: iso8601-{{ checksum "Gemfile.lock" }} paths: - vendor/bundle # Run minitest - type: shell command: bundle exec rspec # Save artifacts - type: store_test_results path: /tmp/test-results ISO8601-0.12.1/.dockerignore000066400000000000000000000001201336436112400152140ustar00rootroot00000000000000.git .editorconfig .rubocop.yml .travis.yml .vagrant .yardoc pkg .bundle bundle ISO8601-0.12.1/.editorconfig000066400000000000000000000002421336436112400152220ustar00rootroot00000000000000root = 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.12.1/.gitignore000066400000000000000000000003071336436112400145370ustar00rootroot00000000000000# 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.12.1/.rubocop.yml000066400000000000000000000010451336436112400150210ustar00rootroot00000000000000AllCops: Exclude: - bundle/vendors/**/* Documentation: Enabled: false Lint/UselessComparison: Enabled: false Metrics/ClassLength: Max: 150 # Work in progress Metrics/LineLength: Max: 183 # Work in progress Metrics/MethodLength: Max: 24 # Work in progress Metrics/PerceivedComplexity: Max: 8 Style/NumericLiterals: MinDigits: 10 Style/StringLiterals: Enabled: false Style/Encoding: EnforcedStyle: when_needed Style/BracesAroundHashParameters: EnforcedStyle: braces Metrics/BlockLength: Exclude: - spec/**/* ISO8601-0.12.1/.travis.yml000066400000000000000000000001621336436112400146570ustar00rootroot00000000000000sudo: false language: ruby rvm: - 2.5.0 - 2.4.0 - ruby-head - jruby-19mode script: bundle exec rspec spec ISO8601-0.12.1/CHANGELOG.md000066400000000000000000000066001336436112400143620ustar00rootroot00000000000000## 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.12.1/CODE_OF_CONDUCT.md000066400000000000000000000044641336436112400153560ustar00rootroot00000000000000# 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.12.1/CONTRIBUTING.md000066400000000000000000000016031336436112400150000ustar00rootroot00000000000000# 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 [Docker](https://docker.com): ```sh make install ``` But of course you can go raw style ```sh bundle install ``` Add your code and tests and check it passes: ```sh make test # mri, jruby # or make mri-test make jruby-test ``` Or raw style ```sh bundle exec rspec ``` Although not required, try to adhere to Rubocop's checks: ```sh make check ``` Or raw style ```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.12.1/Dockerfile000066400000000000000000000003041336436112400145360ustar00rootroot00000000000000FROM ruby:2.5-slim MAINTAINER Arnau Siches RUN mkdir -p /usr/src/iso8601 WORKDIR /usr/src/iso8601 COPY . /usr/src/iso8601 RUN bundle install CMD ["bundle", "exec", "rspec"] ISO8601-0.12.1/Dockerfile.jruby000066400000000000000000000002761336436112400157000ustar00rootroot00000000000000FROM jruby:9 MAINTAINER Arnau Siches RUN mkdir -p /usr/src/iso8601 WORKDIR /usr/src/iso8601 COPY . /usr/src/iso8601 RUN bundle install CMD ["bundle", "exec", "rspec"] ISO8601-0.12.1/Gemfile000066400000000000000000000000461336436112400140420ustar00rootroot00000000000000source 'http://rubygems.org' gemspec ISO8601-0.12.1/LICENSE000066400000000000000000000020631336436112400135550ustar00rootroot00000000000000Copyright (c) 2012-2018 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.12.1/Makefile000066400000000000000000000014231336436112400142070ustar00rootroot00000000000000EXTERNAL_PATH ?= $(PWD) GEM_CREDENTIALS ?= $(HOME)/.gem/credentials VERSION ?= $(shell $(CAT) $(EXTERNAL_PATH)/lib/iso8601/version.rb \ | $(GREP) VERSION \ | $(AWK) '{print $$3}' \ | $(TR) -d \') AWK ?= awk CAT ?= cat DOCKER ?= docker DOCKER_TASK ?= $(DOCKER) run --rm -it GIT ?= git GREP ?= grep TR ?= tr image_name = arnau/iso8601 internal_path = /usr/src/iso8601 volumes = -v $(EXTERNAL_PATH):$(internal_path) \ -v $(GEM_CREDENTIALS):/root/.gem/credentials default: build include mk/*.mk test: mri-test jruby-test install: mri-pull jruby-pull clean: mri-clean jruby-clean build: mri-build jruby-build doc: mri-doc repl: mri-repl shell: mri-shell check: mri-check local-install: bundle install --path bundle/vendors ISO8601-0.12.1/README.md000066400000000000000000000034561336436112400140360ustar00rootroot00000000000000# ISO8601 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. [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/arnau/ISO8601?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 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.x * JRuby 9 ## 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 ### Docker # Install Docker $ make install $ make test You can alse target specific runtimes: $ make mri-test $ make jruby-test ### Raw The old fashion way: # Install a Ruby flavour $ bundle install $ bundle exec rspec ## 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.12.1/Rakefile000066400000000000000000000000341336436112400142110ustar00rootroot00000000000000require 'bundler/gem_tasks' ISO8601-0.12.1/docs/000077500000000000000000000000001336436112400134775ustar00rootroot00000000000000ISO8601-0.12.1/docs/date-time.md000066400000000000000000000046001336436112400156720ustar00rootroot00000000000000# 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.12.1/docs/duration.md000066400000000000000000000037271336436112400156570ustar00rootroot00000000000000# 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