time 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85ec62f9bc0a6c24e4fa69d2aff1c055e49c73cc68daa9ecbcb663c5c7a22d3b
4
- data.tar.gz: 5eabd0bf9fd0c3af11ebc2c3d2ad126bd33bec59f4e2be888fa8805a1eaecbf2
3
+ metadata.gz: 01ec7646c0aa3fd277a865dee712c2f5e97343803376d57660a4d7b494b1e35f
4
+ data.tar.gz: 3b2b35d2938f05a4e8b6b484296c632b0963eb7fccc581b2198f4a467d9db536
5
5
  SHA512:
6
- metadata.gz: 9eccf100eba636071c06ee2fdbe9e9b696344b2789156869e217577c5da32e2111dd9c7004356a8a9a596361eeb4b29d51200797a32c2e17cb1467871f8fdaad
7
- data.tar.gz: 9b6c2b038457f1e5cf6e0061125fd916c74ddd9937d6d66f44c8a6cfffe9e3e6a3669ad6611919de3272f33416fa3d67620d72cb806af32d27aa152f6183c9a1
6
+ metadata.gz: eee9ccbee2fa24d6a4d43d80d95696a4bbde54c89eb21f958e5c3035126b4d4fb5941834953c68cc6ca025ddcf8711cbbde5a2c97ee263cce9a4ad482ba5fb4a
7
+ data.tar.gz: 8fe4756d54b2ec60ef47d1ee4f85e1815ac0d5e49c8a820f3501e173d6b302e094ab89008f0f76cd40f84642b1d1a23ade4e9f356fca66078397979802712254
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
5
5
  are met:
6
6
  1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
7
+ notice, this list of conditions and the following disclaimer.
8
8
  2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
13
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/lib/time.rb CHANGED
@@ -26,7 +26,7 @@ require 'date'
26
26
 
27
27
  class Time
28
28
 
29
- VERSION = "0.3.0"
29
+ VERSION = "0.4.0"
30
30
 
31
31
  class << Time
32
32
 
@@ -391,6 +391,8 @@ class Time
391
391
  # heuristic to detect the format of the input string, you provide
392
392
  # a second argument that describes the format of the string.
393
393
  #
394
+ # Raises `ArgumentError` if the date or format is invalid.
395
+ #
394
396
  # If a block is given, the year described in +date+ is converted by the
395
397
  # block. For example:
396
398
  #
@@ -455,7 +457,7 @@ class Time
455
457
  #
456
458
  def strptime(date, format, now=self.now)
457
459
  d = Date._strptime(date, format)
458
- raise ArgumentError, "invalid date or strptime format - `#{date}' `#{format}'" unless d
460
+ raise ArgumentError, "invalid date or strptime format - '#{date}' '#{format}'" unless d
459
461
  if seconds = d[:seconds]
460
462
  if sec_fraction = d[:sec_fraction]
461
463
  usec = sec_fraction * 1000000
@@ -693,35 +695,36 @@ class Time
693
695
  getutc.strftime('%a, %d %b %Y %T GMT')
694
696
  end
695
697
 
696
- #
697
- # Returns a string which represents the time as a dateTime defined by XML
698
- # Schema:
699
- #
700
- # CCYY-MM-DDThh:mm:ssTZD
701
- # CCYY-MM-DDThh:mm:ss.sssTZD
702
- #
703
- # where TZD is Z or [+-]hh:mm.
704
- #
705
- # If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.
706
- #
707
- # +fraction_digits+ specifies a number of digits to use for fractional
708
- # seconds. Its default value is 0.
709
- #
710
- # require 'time'
711
- #
712
- # t = Time.now
713
- # t.iso8601 # => "2011-10-05T22:26:12-04:00"
714
- #
715
- # You must require 'time' to use this method.
716
- #
717
- def xmlschema(fraction_digits=0)
718
- fraction_digits = fraction_digits.to_i
719
- s = strftime("%FT%T")
720
- if fraction_digits > 0
721
- s << strftime(".%#{fraction_digits}N")
698
+ unless method_defined?(:xmlschema)
699
+ #
700
+ # Returns a string which represents the time as a dateTime defined by XML
701
+ # Schema:
702
+ #
703
+ # CCYY-MM-DDThh:mm:ssTZD
704
+ # CCYY-MM-DDThh:mm:ss.sssTZD
705
+ #
706
+ # where TZD is Z or [+-]hh:mm.
707
+ #
708
+ # If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.
709
+ #
710
+ # +fraction_digits+ specifies a number of digits to use for fractional
711
+ # seconds. Its default value is 0.
712
+ #
713
+ # require 'time'
714
+ #
715
+ # t = Time.now
716
+ # t.iso8601 # => "2011-10-05T22:26:12-04:00"
717
+ #
718
+ # You must require 'time' to use this method.
719
+ #
720
+ def xmlschema(fraction_digits=0)
721
+ fraction_digits = fraction_digits.to_i
722
+ s = strftime("%FT%T")
723
+ if fraction_digits > 0
724
+ s << strftime(".%#{fraction_digits}N")
725
+ end
726
+ s << (utc? ? 'Z' : strftime("%:z"))
722
727
  end
723
- s << (utc? ? 'Z' : strftime("%:z"))
724
728
  end
725
- alias iso8601 xmlschema
729
+ alias iso8601 xmlschema unless method_defined?(:iso8601)
726
730
  end
727
-
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanaka Akira
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-11-07 00:00:00.000000000 Z
10
+ date: 2024-09-06 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: date
@@ -31,17 +30,10 @@ executables: []
31
30
  extensions: []
32
31
  extra_rdoc_files: []
33
32
  files:
34
- - ".github/dependabot.yml"
35
- - ".github/workflows/test.yml"
36
- - ".gitignore"
37
- - Gemfile
38
- - LICENSE.txt
33
+ - BSDL
34
+ - COPYING
39
35
  - README.md
40
- - Rakefile
41
- - bin/console
42
- - bin/setup
43
36
  - lib/time.rb
44
- - time.gemspec
45
37
  homepage: https://github.com/ruby/time
46
38
  licenses:
47
39
  - Ruby
@@ -49,7 +41,6 @@ licenses:
49
41
  metadata:
50
42
  homepage_uri: https://github.com/ruby/time
51
43
  source_code_uri: https://github.com/ruby/time
52
- post_install_message:
53
44
  rdoc_options: []
54
45
  require_paths:
55
46
  - lib
@@ -64,8 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
55
  - !ruby/object:Gem::Version
65
56
  version: '0'
66
57
  requirements: []
67
- rubygems_version: 3.5.0.dev
68
- signing_key:
58
+ rubygems_version: 3.6.0.dev
69
59
  specification_version: 4
70
60
  summary: Extends the Time class with methods for parsing and conversion.
71
61
  test_files: []
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: 'github-actions'
4
- directory: '/'
5
- schedule:
6
- interval: 'weekly'
@@ -1,28 +0,0 @@
1
- name: ubuntu
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- ruby-versions:
7
- uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
- with:
9
- engine: cruby
10
- min_version: 2.6
11
-
12
- build:
13
- needs: ruby-versions
14
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
15
- strategy:
16
- matrix:
17
- ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
18
- os: [ ubuntu-latest, macos-latest ]
19
- runs-on: ${{ matrix.os }}
20
- steps:
21
- - uses: actions/checkout@v4
22
- - name: Set up Ruby
23
- uses: ruby/setup-ruby@v1
24
- with:
25
- ruby-version: ${{ matrix.ruby }}
26
- bundler-cache: true
27
- - name: Run test
28
- run: bundle exec rake test
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in time.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "test-unit"
8
- gem "test-unit-ruby-core"
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test/lib"
6
- t.ruby_opts << "-rhelper"
7
- t.test_files = FileList["test/**/test_*.rb"]
8
- end
9
-
10
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "time"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/time.gemspec DELETED
@@ -1,31 +0,0 @@
1
- name = File.basename(__FILE__, ".gemspec")
2
- version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
3
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
4
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
5
- end rescue nil
6
- end
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = name
10
- spec.version = version
11
- spec.authors = ["Tanaka Akira"]
12
- spec.email = ["akr@fsij.org"]
13
-
14
- spec.summary = %q{Extends the Time class with methods for parsing and conversion.}
15
- spec.description = %q{Extends the Time class with methods for parsing and conversion.}
16
- spec.homepage = "https://github.com/ruby/time"
17
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
18
- spec.licenses = ["Ruby", "BSD-2-Clause"]
19
-
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = spec.homepage
22
-
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
29
-
30
- spec.add_dependency "date"
31
- end