strftime 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in strftime.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ == MIT License
2
+
3
+ Copyright (c) 2010, Jim Gay, Saturn Flyer LLC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README ADDED
@@ -0,0 +1,11 @@
1
+ # strftime
2
+
3
+ With strftime you'll have descriptions of time format directives at your fingertips in Ruby.
4
+
5
+ `Strftime::Directives` contains a hash of details about these directives.
6
+
7
+ Just use `Strftime::Directives['%M']` to get a description and example, or use the shorthand method `strfd('M')`
8
+
9
+ Strftime::Directives['%M'].description #=> 'Minute of the hour'
10
+
11
+ This might be useful for you, or for users of a system which are able to specify string formats for dates and times.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,67 @@
1
+ module Strftime
2
+ Directives = Hash.new do |hash, key|
3
+ mod = ('%' << key.to_s)
4
+ hash[mod] if hash.keys.include?(mod)
5
+ end
6
+ Directives.merge!({
7
+ '%a' => { :description => 'The abbreviated weekday name', :example => "Sun"},
8
+ '%A' => { :description => 'The full weekday name', :example => "Sunday"},
9
+ '%b' => { :description => 'The abbreviated month name', :example => "Jan"},
10
+ '%B' => { :description => 'The full month name', :example => "January"},
11
+ '%c' => { :description => 'The preferred local date and time representation'},
12
+ '%C' => { :description => 'Century (20 in 2009)'},
13
+ '%d' => { :description => 'Day of the month', :example => "01..31"},
14
+ '%D' => { :description => 'Date (%m/%d/%y)'},
15
+ '%e' => { :description => 'Day of the month, blank-padded', :example => "1..31"},
16
+ '%F' => { :description => 'Equivalent to %Y-%m-%d (the ISO 8601 date format)'},
17
+ '%h' => { :description => 'Equivalent to %b'},
18
+ '%H' => { :description => 'Hour of the day, 24-hour clock', :example => "00..23"},
19
+ '%I' => { :description => 'Hour of the day, 12-hour clock', :example => "01..12)"},
20
+ '%j' => { :description => 'Day of the year', :example => "001..366"},
21
+ '%k' => { :description => 'hour, 24-hour clock, blank-padded', :example => "0..23"},
22
+ '%l' => { :description => 'hour, 12-hour clock, blank-padded', :example => "0..12"},
23
+ '%L' => { :description => 'Millisecond of the second', :example => "000..999"},
24
+ '%m' => { :description => 'Month of the year', :example => "01..12"},
25
+ '%M' => { :description => 'Minute of the hour', :example => "00..59"},
26
+ '%n' => { :description => 'Newline (\n)'},
27
+ '%N' => { :description => 'Fractional seconds digits, default is 9 digits (nanosecond)
28
+ %3N millisecond (3 digits)
29
+ %6N microsecond (6 digits)
30
+ %9N nanosecond (9 digits)'},
31
+ '%p' => { :description => 'Meridian indicator', :example => "(``AM'' or ``PM'')"},
32
+ '%P' => { :description => 'Meridian indicator', :example => "(``am'' or ``pm'')"},
33
+ '%r' => { :description => 'time, 12-hour', :example => "same as %I:%M:%S %p"},
34
+ '%R' => { :description => 'time, 24-hour', :example => "%H:%M"},
35
+ '%s' => { :description => 'Number of seconds since 1970-01-01 00:00:00 UTC.'},
36
+ '%S' => { :description => 'Second of the minute', :example => "00..60"},
37
+ '%t' => { :description => 'Tab character', :example => "\t"},
38
+ '%T' => { :description => 'time, 24-hour', :example => "%H:%M:%S"},
39
+ '%u' => { :description => 'Day of the week as a decimal, Monday being 1.', :example => "1..7"},
40
+ '%U' => { :description => 'Week number of the current year,
41
+ starting with the first Sunday as the first
42
+ day of the first week', :example => "00..53"},
43
+ '%v' => { :description => 'VMS date', :example => "%e-%b-%Y"},
44
+ '%V' => { :description => 'Week number of year according to ISO 8601', :example => "01..53"},
45
+ '%W' => { :description => 'Week number of the current year,
46
+ starting with the first Monday as the first
47
+ day of the first week', :example => "00..53"},
48
+ '%w' => { :description => 'Day of the week', :example => "Sunday is 0, 0..6"},
49
+ '%x' => { :description => 'Preferred representation for the date alone, no time'},
50
+ '%X' => { :description => 'Preferred representation for the time alone, no date'},
51
+ '%y' => { :description => 'Year without a century', :example => "00..99"},
52
+ '%Y' => { :description => 'Year with century'},
53
+ '%z' => { :description => 'Time zone as hour offset from UTC (e.g. +0900)'},
54
+ '%Z' => { :description => 'Time zone name'},
55
+ '%%' => { :description => "Literal ``%'' character"}
56
+ })
57
+ end
58
+
59
+ class Object
60
+ def strfd(arg=nil)
61
+ if arg
62
+ Strftime::Directives[arg]
63
+ else
64
+ Strftime::Directives
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,3 @@
1
+ module Strftime
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "strftime/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "strftime"
7
+ s.version = Strftime::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jim Gay"]
10
+ s.email = ["jim@saturnflyer.com"]
11
+ s.homepage = "http://rubygems.org/gems/strftime"
12
+ s.summary = %q{Convenient list of strftime format directives}
13
+ s.description = %q{Convenient list of strftime format directives}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.post_install_message = %{
21
+ Thanks for installing strftime. You can use these methods to
22
+ better understand the formats used in Date and Time strftime
23
+
24
+ Strftime::Directives #=> a full hash of directives
25
+ Strftime::Directives['%y'] #=> a hash of description and
26
+ # optional example value
27
+
28
+ Strftime::Directives['y'] #=> optionally exclude the %
29
+
30
+ strfd #=> shorthand to get directives
31
+ strfd('y') #=> shorthand to get details
32
+ }
33
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strftime
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Jim Gay
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-04 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Convenient list of strftime format directives
23
+ email:
24
+ - jim@saturnflyer.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README
36
+ - Rakefile
37
+ - lib/strftime.rb
38
+ - lib/strftime/version.rb
39
+ - strftime.gemspec
40
+ has_rdoc: true
41
+ homepage: http://rubygems.org/gems/strftime
42
+ licenses: []
43
+
44
+ post_install_message: "\n Thanks for installing strftime. You can use these methods to\n better understand the formats used in Date and Time strftime\n \n Strftime::Directives #=> a full hash of directives\n Strftime::Directives['%y'] #=> a hash of description and \n # optional example value\n \n Strftime::Directives['y'] #=> optionally exclude the %\n \n strfd #=> shorthand to get directives\n strfd('y') #=> shorthand to get details\n "
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.7
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Convenient list of strftime format directives
74
+ test_files: []
75
+