strptime 0.1.0-x86-mingw32 → 0.1.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/README.md +9 -8
- data/Rakefile +8 -0
- data/appveyor.yml +18 -0
- data/ext/strptime/strptime.c +39 -47
- data/lib/strptime/version.rb +1 -1
- data/strptime.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 792bc1fd530e99a5101bcefb573daec33065118d
|
4
|
+
data.tar.gz: ef1c1ffec07a980158a58de0ab66ff1a8d76f1f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8ecd1cf00fdde3bd0c8a40d80717bdaed7d7fd90ee52b455181ea3564bc1610ac7f271980380d0289e36904da45fc57d7cc94533dd977dc6dbb003454d194a
|
7
|
+
data.tar.gz: 712482f45d39b81bd429a90865fa0a746bb496c65f91086c8165ee6227304d1280521fd4ff7dff7dad81af33fbcf4c1784dbdf2f8519607e493715853200db4a
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Strptime
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/nurse/strptime.png)](https://travis-ci.org/nurse/strptime)
|
4
|
+
[![Build status](https://ci.appveyor.com/api/projects/status/9wr116l8uy1bdcxf/branch/master?svg=true)](https://ci.appveyor.com/project/nurse/strptime/branch/master)
|
5
|
+
|
4
6
|
|
5
7
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/strptime`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
8
|
|
@@ -24,17 +26,16 @@ Or install it yourself as:
|
|
24
26
|
|
25
27
|
## Usage
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
29
|
+
```ruby
|
30
|
+
require 'strptime'
|
31
|
+
parser = Strptime.new('%Y-%m-%dT%H:%M:%S%z')
|
32
|
+
parser.exec('2015-12-25T12:34:56+09') #=> 2015-12-25 12:34:56 +09:00
|
33
|
+
parser.execi('2015-12-25T12:34:56+09') #=> 1451014496
|
34
|
+
```
|
34
35
|
|
35
36
|
## Contributing
|
36
37
|
|
37
|
-
1. Fork it ( https://github.com/
|
38
|
+
1. Fork it ( https://github.com/nurse/strptime/fork )
|
38
39
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
40
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
41
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "bundler"
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
require "rspec/core/rake_task"
|
4
|
+
require 'yard'
|
4
5
|
|
5
6
|
RSpec::Core::RakeTask.new(:spec)
|
6
7
|
|
@@ -10,6 +11,13 @@ require "rake/extensiontask"
|
|
10
11
|
task :build => :compile
|
11
12
|
task :spec => :compile
|
12
13
|
|
14
|
+
desc 'Generate YARD document'
|
15
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
16
|
+
t.files = ['ext/strptime/strptime.c']
|
17
|
+
t.options = []
|
18
|
+
t.options << '--debug' << '--verbose' if $trace
|
19
|
+
end
|
20
|
+
|
13
21
|
spec = eval File.read("strptime.gemspec")
|
14
22
|
Rake::ExtensionTask.new("strptime", spec) do |ext|
|
15
23
|
ext.ext_dir = 'ext/strptime'
|
data/appveyor.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
install:
|
3
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
4
|
+
- ruby --version
|
5
|
+
- gem --version
|
6
|
+
- bundle install
|
7
|
+
build: off
|
8
|
+
test_script:
|
9
|
+
- bundle exec rake -rdevkit
|
10
|
+
|
11
|
+
environment:
|
12
|
+
matrix:
|
13
|
+
- ruby_version: "200"
|
14
|
+
- ruby_version: "200-x64"
|
15
|
+
- ruby_version: "21"
|
16
|
+
- ruby_version: "21-x64"
|
17
|
+
- ruby_version: "22"
|
18
|
+
- ruby_version: "22-x64"
|
data/ext/strptime/strptime.c
CHANGED
@@ -120,7 +120,6 @@ strptime_exec0(void **pc, const char *fmt, const char *str, size_t slen,
|
|
120
120
|
return 0;
|
121
121
|
}
|
122
122
|
|
123
|
-
first:
|
124
123
|
INSN_DISPATCH();
|
125
124
|
INSN_ENTRY(A)
|
126
125
|
{
|
@@ -403,7 +402,13 @@ first:
|
|
403
402
|
size_t v = (size_t)GET_OPERAND(1);
|
404
403
|
size_t fi = v & 0xFFFF;
|
405
404
|
size_t cnt = v >> 16;
|
406
|
-
|
405
|
+
/* optimize to short string instead of memcmp(3) */
|
406
|
+
const char *p = str + si;
|
407
|
+
const char *q = fmt + fi;
|
408
|
+
const char *qe = q + cnt;
|
409
|
+
for (; q < qe; p++,q++) {
|
410
|
+
if (*p != *q) return Qnil;
|
411
|
+
}
|
407
412
|
pc += 2;
|
408
413
|
si += cnt;
|
409
414
|
END_INSN(_60)
|
@@ -419,26 +424,21 @@ first:
|
|
419
424
|
{
|
420
425
|
static time_t ct;
|
421
426
|
static struct tm ctm;
|
422
|
-
static long
|
423
|
-
static long
|
424
|
-
|
425
|
-
if (ct == ts.tv_sec) {
|
426
|
-
off = cgmtoff;
|
427
|
-
}
|
428
|
-
else {
|
427
|
+
static long ctmoff;
|
428
|
+
static long localoff;
|
429
|
+
if (ct != ts.tv_sec) {
|
429
430
|
ct = ts.tv_sec;
|
430
|
-
localtime_with_gmtoff_zone(&ct, &ctm, &
|
431
|
-
|
432
|
-
cgmtoff = INT_MAX;
|
431
|
+
localtime_with_gmtoff_zone(&ct, &ctm, &ctmoff, NULL);
|
432
|
+
localoff = ctmoff;
|
433
433
|
}
|
434
434
|
if (gmtoff == INT_MAX) {
|
435
|
-
gmtoff =
|
435
|
+
gmtoff = localoff;
|
436
436
|
}
|
437
|
-
if (gmtoff !=
|
438
|
-
tm_add_offset(&ctm, gmtoff -
|
437
|
+
if (gmtoff != ctmoff) {
|
438
|
+
tm_add_offset(&ctm, gmtoff - ctmoff);
|
439
|
+
ctmoff = gmtoff;
|
439
440
|
}
|
440
441
|
memcpy(&tm, &ctm, sizeof(struct tm));
|
441
|
-
cgmtoff = gmtoff;
|
442
442
|
}
|
443
443
|
|
444
444
|
/* overwrite time */
|
@@ -467,22 +467,7 @@ first:
|
|
467
467
|
if (sec != -1) tm.tm_sec = sec;
|
468
468
|
}
|
469
469
|
|
470
|
-
|
471
|
-
static time_t ct;
|
472
|
-
static struct tm cache;
|
473
|
-
/* struct tm to time_t */
|
474
|
-
if (ct && cache.tm_year == tm.tm_year &&
|
475
|
-
cache.tm_mon == tm.tm_mon && cache.tm_mday == tm.tm_mday) {
|
476
|
-
t = ct + (tm.tm_hour - cache.tm_hour) * 3600 +
|
477
|
-
(tm.tm_min - cache.tm_min) * 60 +
|
478
|
-
(tm.tm_sec - cache.tm_sec);
|
479
|
-
}
|
480
|
-
else {
|
481
|
-
ct = t = timegm_noleapsecond(&tm);
|
482
|
-
memcpy((void *)&cache, &tm, sizeof(struct tm));
|
483
|
-
}
|
484
|
-
t -= gmtoff;
|
485
|
-
}
|
470
|
+
t = timegm_noleapsecond(&tm) - gmtoff;
|
486
471
|
tsp->tv_sec = t;
|
487
472
|
tsp->tv_nsec = nsec;
|
488
473
|
*gmtoffp = gmtoff;
|
@@ -493,7 +478,7 @@ first:
|
|
493
478
|
|
494
479
|
/* unreachable */
|
495
480
|
rb_bug("vm_eval: unreachable");
|
496
|
-
|
481
|
+
UNREACHABLE;
|
497
482
|
}
|
498
483
|
|
499
484
|
void **
|
@@ -628,8 +613,8 @@ get_new_strptimeval(VALUE obj)
|
|
628
613
|
}
|
629
614
|
|
630
615
|
/*
|
631
|
-
*
|
632
|
-
*
|
616
|
+
* @overload new(format)
|
617
|
+
* @param format [String] strptime(3) style format string.
|
633
618
|
*
|
634
619
|
* returns parser object
|
635
620
|
*/
|
@@ -638,7 +623,7 @@ strptime_init(VALUE self, VALUE fmt)
|
|
638
623
|
{
|
639
624
|
struct strptime_object *tobj;
|
640
625
|
void **isns;
|
641
|
-
|
626
|
+
StringValueCStr(fmt);
|
642
627
|
TypedData_Get_Struct(self, struct strptime_object, &strptime_data_type,
|
643
628
|
tobj);
|
644
629
|
isns = strptime_compile(RSTRING_PTR(fmt), RSTRING_LEN(fmt));
|
@@ -647,7 +632,9 @@ strptime_init(VALUE self, VALUE fmt)
|
|
647
632
|
return self;
|
648
633
|
}
|
649
634
|
|
650
|
-
/*
|
635
|
+
/* @api private
|
636
|
+
* For Ruby VM internal.
|
637
|
+
*/
|
651
638
|
static VALUE
|
652
639
|
strptime_init_copy(VALUE copy, VALUE self)
|
653
640
|
{
|
@@ -688,9 +675,11 @@ PACKED_STRUCT_UNALIGNED(struct time_object {
|
|
688
675
|
});
|
689
676
|
|
690
677
|
/*
|
691
|
-
*
|
692
|
-
*
|
678
|
+
* @overload exec(str)
|
679
|
+
* @param str [String] string to parse
|
680
|
+
* @return [Time] the time object given string means
|
693
681
|
*
|
682
|
+
* Parse given string, and return Time object
|
694
683
|
*
|
695
684
|
*/
|
696
685
|
static VALUE
|
@@ -709,10 +698,11 @@ strptime_exec(VALUE self, VALUE str)
|
|
709
698
|
}
|
710
699
|
|
711
700
|
/*
|
712
|
-
*
|
713
|
-
*
|
701
|
+
* @overload execi(str)
|
702
|
+
* @param str [String] string to parse
|
703
|
+
* @return [Integer] the Unix epoch given string means
|
714
704
|
*
|
715
|
-
*
|
705
|
+
* Parse given string, and return epoch as integer
|
716
706
|
*/
|
717
707
|
static VALUE
|
718
708
|
strptime_execi(VALUE self, VALUE str)
|
@@ -730,10 +720,8 @@ strptime_execi(VALUE self, VALUE str)
|
|
730
720
|
}
|
731
721
|
|
732
722
|
/*
|
733
|
-
*
|
734
|
-
*
|
735
|
-
*
|
736
|
-
* returns source format string
|
723
|
+
* @overload source
|
724
|
+
* @return [String] source format string
|
737
725
|
*/
|
738
726
|
static VALUE
|
739
727
|
strptime_source(VALUE self)
|
@@ -745,9 +733,13 @@ strptime_source(VALUE self)
|
|
745
733
|
}
|
746
734
|
|
747
735
|
/*
|
748
|
-
*
|
736
|
+
* Document-class: Strptime
|
737
|
+
*
|
738
|
+
* Strptime is a faster way to parse time strings like strptime(3).
|
749
739
|
*
|
740
|
+
* @example
|
750
741
|
* parser = Strptime.new('%Y-%m-%dT%H:%M:%S%z')
|
742
|
+
* parser.source #=> "%Y-%m-%dT%H:%M:%S%z"
|
751
743
|
* parser.exec('2015-12-25T12:34:56+09') #=> 2015-12-25 12:34:56 +09:00
|
752
744
|
* parser.execi('2015-12-25T12:34:56+09') #=> 1451014496
|
753
745
|
*/
|
data/lib/strptime/version.rb
CHANGED
data/strptime.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strptime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- NARUSE, Yui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: a fast strptime engine which uses VM.
|
84
98
|
email:
|
85
99
|
- naruse@airemix.jp
|
@@ -95,6 +109,7 @@ files:
|
|
95
109
|
- LICENSE.txt
|
96
110
|
- README.md
|
97
111
|
- Rakefile
|
112
|
+
- appveyor.yml
|
98
113
|
- bin/console
|
99
114
|
- bin/setup
|
100
115
|
- ext/strptime/extconf.rb
|