time 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85ec62f9bc0a6c24e4fa69d2aff1c055e49c73cc68daa9ecbcb663c5c7a22d3b
4
- data.tar.gz: 5eabd0bf9fd0c3af11ebc2c3d2ad126bd33bec59f4e2be888fa8805a1eaecbf2
3
+ metadata.gz: c211ffd223b56fae14493d2d7fb187ac2e7fa4f089943fba05174f0ee9549c4c
4
+ data.tar.gz: df4434890036e502a795ac24cfb93920ace49539b4ef2f092942cdef049ba141
5
5
  SHA512:
6
- metadata.gz: 9eccf100eba636071c06ee2fdbe9e9b696344b2789156869e217577c5da32e2111dd9c7004356a8a9a596361eeb4b29d51200797a32c2e17cb1467871f8fdaad
7
- data.tar.gz: 9b6c2b038457f1e5cf6e0061125fd916c74ddd9937d6d66f44c8a6cfffe9e3e6a3669ad6611919de3272f33416fa3d67620d72cb806af32d27aa152f6183c9a1
6
+ metadata.gz: 247084d1b3bbdda9a0f21652daf9d729a2f32d3aa89a16c3e4b78d305c49fa487c75386a80ebcd88b9bf0ccec224ae1aa1989baa4a96bbdb88e580b97812521f
7
+ data.tar.gz: 578f214835d4259e3a4cd9aff080806b29a04c886b90f8acd4f95527af581698722423fd85a4ef3e0d911b7f8f797adfdddfb3239c4cba20e4970299271b3a70
@@ -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.1" # :nodoc:
30
30
 
31
31
  class << Time
32
32
 
@@ -280,7 +280,7 @@ class Time
280
280
  #
281
281
  # This method **does not** function as a validator. If the input
282
282
  # string does not match valid formats strictly, you may get a
283
- # cryptic result. Should consider to use `Time.strptime` instead
283
+ # cryptic result. Should consider to use Time.strptime instead
284
284
  # of this method as possible.
285
285
  #
286
286
  # require 'time'
@@ -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
  #
@@ -405,7 +407,7 @@ class Time
405
407
  # %c :: The preferred local date and time representation
406
408
  # %C :: Century (20 in 2009)
407
409
  # %d :: Day of the month (01..31)
408
- # %D :: Date (%m/%d/%y)
410
+ # %D :: \Date (%m/%d/%y)
409
411
  # %e :: Day of the month, blank-padded ( 1..31)
410
412
  # %F :: Equivalent to %Y-%m-%d (the ISO 8601 date format)
411
413
  # %g :: The last two digits of the commercial year
@@ -442,8 +444,8 @@ class Time
442
444
  # %X :: Preferred representation for the time alone, no date
443
445
  # %y :: Year without a century (00..99)
444
446
  # %Y :: Year which may include century, if provided
445
- # %z :: Time zone as hour offset from UTC (e.g. +0900)
446
- # %Z :: Time zone name
447
+ # %z :: \Time zone as hour offset from UTC (e.g. +0900)
448
+ # %Z :: \Time zone name
447
449
  # %% :: Literal "%" character
448
450
  # %+ :: date(1) (%a %b %e %H:%M:%S %Z %Y)
449
451
  #
@@ -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,14 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanaka Akira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-07 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: date
@@ -31,17 +31,10 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".github/dependabot.yml"
35
- - ".github/workflows/test.yml"
36
- - ".gitignore"
37
- - Gemfile
38
- - LICENSE.txt
34
+ - BSDL
35
+ - COPYING
39
36
  - README.md
40
- - Rakefile
41
- - bin/console
42
- - bin/setup
43
37
  - lib/time.rb
44
- - time.gemspec
45
38
  homepage: https://github.com/ruby/time
46
39
  licenses:
47
40
  - Ruby
@@ -49,7 +42,7 @@ licenses:
49
42
  metadata:
50
43
  homepage_uri: https://github.com/ruby/time
51
44
  source_code_uri: https://github.com/ruby/time
52
- post_install_message:
45
+ post_install_message:
53
46
  rdoc_options: []
54
47
  require_paths:
55
48
  - lib
@@ -64,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
57
  - !ruby/object:Gem::Version
65
58
  version: '0'
66
59
  requirements: []
67
- rubygems_version: 3.5.0.dev
68
- signing_key:
60
+ rubygems_version: 3.5.11
61
+ signing_key:
69
62
  specification_version: 4
70
63
  summary: Extends the Time class with methods for parsing and conversion.
71
64
  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