date 3.2.2 → 3.3.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: 91f6620791550924cc059c5c534ada4a811b273d900399be6c4406801a4dbcc6
4
- data.tar.gz: 68b1c8be2eb0aefffd9b5fe450a03834655cbe3d8892682778f24ad0102920ca
3
+ metadata.gz: 45f9dbfb1646ace90580d6570a44a1bb30d0754e1724d95d714999e94aff623c
4
+ data.tar.gz: 95773c2dc052bcb4e14d17eef85ec9d8bf9d743d3c050fea36ba698c6211b1e7
5
5
  SHA512:
6
- metadata.gz: 508e707ba98f9a77b0dad3689627d3f5c2dc1a87b84a4b017e09bb4374ddaecebd7c834c75440dc6d8d27f767b971915626073e7bd796d4695e29c54e8e9d73a
7
- data.tar.gz: 1841c19c7365a7f10eb80ab4aac688fcaf68623b7cc39b083b3ff19a2e43b782a2f7f04b77ad3cfa3d4094611f87394d2bb5fe2ca5359a623092f6d4bae60959
6
+ metadata.gz: b32ae525d4bfe627069b342527ff6af61550f1f1d7bafd8de7aa0736a3a48e9333769103987138c4abb86c84ec0ce4389843fb9333d6c8dfe2dd47b7defb7490
7
+ data.tar.gz: 299a268ba590b6a291a6535096e64c02cd45f12e0e7b92114fdba075d932d4e72862c59ad0200e7c034ab74b1fcac47514cd25bc28bb7e7d8696bac685a2b7c2
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # `Date`
2
+
3
+ A subclass of `Object` that includes the `Comparable` module and easily handles date.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'date'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install date
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'date'
25
+ ```
26
+
27
+ A `Date` object is created with `Date::new`, `Date::jd`, `Date::ordinal`, `Date::commercial`, `Date::parse`, `Date::strptime`, `Date::today`, `Time#to_date`, etc.
28
+
29
+ ```ruby
30
+ require 'date'
31
+
32
+ Date.new(2001,2,3)
33
+ #=> #<Date: 2001-02-03 ...>
34
+ Date.jd(2451944)
35
+ #=> #<Date: 2001-02-03 ...>
36
+ Date.ordinal(2001,34)
37
+ #=> #<Date: 2001-02-03 ...>
38
+ Date.commercial(2001,5,6)
39
+ #=> #<Date: 2001-02-03 ...>
40
+ Date.parse('2001-02-03')
41
+ #=> #<Date: 2001-02-03 ...>
42
+ Date.strptime('03-02-2001', '%d-%m-%Y')
43
+ #=> #<Date: 2001-02-03 ...>
44
+ Time.new(2001,2,3).to_date
45
+ #=> #<Date: 2001-02-03 ...>
46
+ ```
47
+
48
+ All `Date` objects are immutable; hence cannot modify themselves.
49
+
50
+ The concept of a date object can be represented as a tuple of the day count, the offset and the day of calendar reform.
51
+
52
+ The day count denotes the absolute position of a temporal dimension. The offset is relative adjustment, which determines decoded local time with the day count. The day of calendar reform denotes the start day of the new style. The old style of the West is the Julian calendar which was adopted by Caesar. The new style is the Gregorian calendar, which is the current civil calendar of many countries.
53
+
54
+ The day count is virtually the astronomical Julian day number. The offset in this class is usually zero, and cannot be specified directly.
55
+
56
+ A `Date` object can be created with an optional argument, the day of calendar reform as a Julian day number, which should be 2298874 to 2426355 or negative/positive infinity. The default value is `Date::ITALY` (2299161=1582-10-15). See also sample/cal.rb.
57
+
58
+ ```
59
+ $ ruby sample/cal.rb -c it 10 1582
60
+ October 1582
61
+ S M Tu W Th F S
62
+ 1 2 3 4 15 16
63
+ 17 18 19 20 21 22 23
64
+ 24 25 26 27 28 29 30
65
+ 31
66
+ ```
67
+
68
+ ```
69
+ $ ruby sample/cal.rb -c gb 9 1752
70
+ September 1752
71
+ S M Tu W Th F S
72
+ 1 2 14 15 16
73
+ 17 18 19 20 21 22 23
74
+ 24 25 26 27 28 29 30
75
+ ```
76
+
77
+ A `Date` object has various methods. See each reference.
78
+
79
+ ```ruby
80
+ d = Date.parse('3rd Feb 2001')
81
+ #=> #<Date: 2001-02-03 ...>
82
+ d.year #=> 2001
83
+ d.mon #=> 2
84
+ d.mday #=> 3
85
+ d.wday #=> 6
86
+ d += 1 #=> #<Date: 2001-02-04 ...>
87
+ d.strftime('%a %d %b %Y') #=> "Sun 04 Feb 2001"
88
+ ```
89
+
90
+ ## Development
91
+
92
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
93
+
94
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
+
96
+ ## Contributing
97
+
98
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/date.
99
+
100
+ ## License
101
+
102
+ The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).