jalalidate 0.2.1 → 0.2.2

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.
data/.gitignore ADDED
@@ -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 jalalidate.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2010 Aziz A. Bargi
1
+ Copyright (c) 2008-2010 Allen A. Bargi
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,22 +1,25 @@
1
- = Jalali Date Library
1
+ # Jalali Date Library
2
2
 
3
- == History
3
+ ## Install
4
+ gem install jalalidate
4
5
 
5
- ==== 0.2 - 25.FEB.2010
6
+ ## History
7
+
8
+ #### 0.2 - 25.FEB.2010
6
9
  * renamed the gem from JalaliDate to jalalidate
7
10
  * added spec and a full test suite
8
11
  * updated gemspec file for rubygems.org
9
12
  * updated some documentations
10
13
 
11
- ==== 0.02 - 08.AUG.2008
14
+ #### 0.02 - 08.AUG.2008
12
15
  * added jalali to geregorian date convertor.
13
16
  * added JalaliDate class and ported Date class method to JalaliDate
14
17
 
15
- ==== 0.01 - 07.AUG.2008
18
+ #### 0.01 - 07.AUG.2008
16
19
  * planning the project
17
20
 
18
21
 
19
- == Note on Patches/Pull Requests
22
+ ## Note on Patches/Pull Requests
20
23
 
21
24
  * Fork the project.
22
25
  * Make your feature addition or bug fix.
@@ -26,6 +29,6 @@
26
29
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
27
30
  * Send me a pull request. Bonus points for topic branches.
28
31
 
29
- == Copyright
32
+ ## Copyright
30
33
 
31
- Copyright (c) 2008-2010 Aziz A. Bargi. See LICENSE for details.
34
+ Copyright (c) 2008-2011 Allen A. Bargi. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,75 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
-
8
- gem.name = "jalalidate"
9
- gem.version = "0.2.1"
10
- gem.authors = ["Aziz A. Bargi"]
11
- gem.email = "aziz.bargi@gmail.com"
12
- gem.rubyforge_project = 'JalaliDate'
13
- gem.homepage = "http://github.com/aziz/jalalidate"
14
- gem.summary = "A library for working with Jalali Calendar (a.k.a Persian Calendar)"
15
- gem.has_rdoc = true
16
- gem.extra_rdoc_files = ["README.rdoc","LICENSE"]
17
- gem.add_development_dependency "rspec", ">= 1.2.9"
18
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
- end
24
-
25
- require 'spec/rake/spectask'
26
- Spec::Rake::SpecTask.new(:spec) do |spec|
27
- spec.libs << 'lib' << 'spec'
28
- spec.spec_files = FileList['spec/**/*_spec.rb']
29
- end
30
-
31
- Spec::Rake::SpecTask.new(:rcov) do |spec|
32
- spec.libs << 'lib' << 'spec'
33
- spec.pattern = 'spec/**/*_spec.rb'
34
- spec.rcov = true
35
- end
36
-
37
- task :spec => :check_dependencies
38
-
39
- begin
40
- require 'reek/adapters/rake_task'
41
- Reek::RakeTask.new do |t|
42
- t.fail_on_error = true
43
- t.verbose = false
44
- t.source_files = 'lib/**/*.rb'
45
- end
46
- rescue LoadError
47
- task :reek do
48
- abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
49
- end
50
- end
51
-
52
- begin
53
- require 'roodi'
54
- require 'roodi_task'
55
- RoodiTask.new do |t|
56
- t.verbose = false
57
- end
58
- rescue LoadError
59
- task :roodi do
60
- abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
61
- end
62
- end
63
-
64
- task :default => :spec
65
-
66
- require 'rake/rdoctask'
67
- Rake::RDocTask.new do |rdoc|
68
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
69
-
70
- rdoc.options << "--charset" << "utf-8"
71
- rdoc.rdoc_dir = 'rdoc'
72
- rdoc.title = "jalalidate #{version}"
73
- rdoc.rdoc_files.include(['README.rdoc','LICENSE'])
74
- rdoc.rdoc_files.include('lib/**/*.rb')
75
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/TODO CHANGED
@@ -1,3 +1,3 @@
1
1
  =TODO
2
2
  * jalali_strftime: Add support for localized time zone names(%z) and add week number of the year %W and %U
3
- * add rails active support date calculation for jalali
3
+ * Add rails active support date calculation for jalali
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jalalidate/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jalalidate"
7
+ s.version = Jalalidate::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Allen A. Bargi"]
10
+ s.email = %q{allen.bargi@gmail.com}
11
+ s.homepage = %q{http://github.com/aziz/jalalidate}
12
+ s.summary = %q{A library for working with Jalali Calendar (a.k.a Persian Calendar)}
13
+ s.description = %q{A library for working with Jalali Calendar (a.k.a Persian Calendar)}
14
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
15
+ s.rubyforge_project = "jalalidate"
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ s.extra_rdoc_files = [ "LICENSE", "README.md"]
21
+ s.rdoc_options = ["--charset=UTF-8"]
22
+ end
data/lib/jalalidate.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # :title:Jalali Date #
2
- require 'jcode'
2
+ require "jcode"
3
3
  require "date"
4
4
 
5
5
  class JalaliDate
@@ -41,9 +41,8 @@ class JalaliDate
41
41
  @g_year, @g_month, @g_day = jalali_to_gregorian(year,month,day)
42
42
  end
43
43
 
44
- # Class Methods
45
- class << self
46
-
44
+ # Class Methods -----------------------------------------------------------
45
+ class << self
47
46
  # Return a JalaliDate object representing today's date in calendar
48
47
  def today
49
48
  JalaliDate.new(Date.today)
@@ -68,15 +67,22 @@ class JalaliDate
68
67
  # Accpets three numbers for year (4 digit), month and day in jalali calendar and checks if it's a
69
68
  # valid date according to jalali calendar or not.
70
69
  def valid?(y,m,d)
71
- (y.class == Fixnum && y > 0 &&
72
- m.class == Fixnum && (1..12).include?(m) &&
73
- d.class == Fixnum && (((1..JDaysInMonth[m-1]).include?(d)) || (d == 30 && m == 12 && leap?(y) ))
70
+ ( y.class == Fixnum && y > 0 &&
71
+ m.class == Fixnum && (1..12).include?(m) &&
72
+ d.class == Fixnum &&
73
+ (
74
+ ((1..JDaysInMonth[m-1]).include?(d)) || (d == 30 && m == 12 && leap?(y))
75
+ )
74
76
  ) ? true : false
75
77
  end
76
78
  end
77
79
 
80
+ # Instance Methods --------------------------------------------------------
81
+
78
82
  # Converts a JalaiDate object to Ruby Date object
79
- def to_gregorian; Date.new(@g_year,@g_month,@g_day); end;
83
+ def to_gregorian
84
+ Date.new(@g_year,@g_month,@g_day)
85
+ end
80
86
  alias :to_g :to_gregorian
81
87
 
82
88
  # Returns a string represtation of the JalaliDate object in format like this: y/m/d
@@ -0,0 +1,3 @@
1
+ module Jalalidate
2
+ VERSION = "0.2.2"
3
+ end
metadata CHANGED
@@ -1,51 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jalalidate
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 1
9
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
10
11
  platform: ruby
11
12
  authors:
12
- - Aziz A. Bargi
13
+ - Allen A. Bargi
13
14
  autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-03 00:00:00 +01:00
18
+ date: 2010-12-24 00:00:00 +01:00
18
19
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 2
30
- - 9
31
- version: 1.2.9
32
- type: :development
33
- version_requirements: *id001
34
- description:
35
- email: aziz.bargi@gmail.com
20
+ dependencies: []
21
+
22
+ description: A library for working with Jalali Calendar (a.k.a Persian Calendar)
23
+ email: allen.bargi@gmail.com
36
24
  executables: []
37
25
 
38
26
  extensions: []
39
27
 
40
28
  extra_rdoc_files:
41
29
  - LICENSE
42
- - README.rdoc
30
+ - README.md
43
31
  files:
32
+ - .gitignore
33
+ - Gemfile
44
34
  - LICENSE
45
- - README.rdoc
35
+ - README.md
46
36
  - Rakefile
47
37
  - TODO
38
+ - jalalidate.gemspec
48
39
  - lib/jalalidate.rb
40
+ - lib/jalalidate/version.rb
49
41
  - spec/jalalidate_spec.rb
50
42
  - spec/spec_helper.rb
51
43
  has_rdoc: true
@@ -58,23 +50,27 @@ rdoc_options:
58
50
  require_paths:
59
51
  - lib
60
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
61
54
  requirements:
62
55
  - - ">="
63
56
  - !ruby/object:Gem::Version
57
+ hash: 3
64
58
  segments:
65
59
  - 0
66
60
  version: "0"
67
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
68
63
  requirements:
69
64
  - - ">="
70
65
  - !ruby/object:Gem::Version
66
+ hash: 3
71
67
  segments:
72
68
  - 0
73
69
  version: "0"
74
70
  requirements: []
75
71
 
76
- rubyforge_project: JalaliDate
77
- rubygems_version: 1.3.6
72
+ rubyforge_project: jalalidate
73
+ rubygems_version: 1.3.7
78
74
  signing_key:
79
75
  specification_version: 3
80
76
  summary: A library for working with Jalali Calendar (a.k.a Persian Calendar)