date 3.0.0 → 3.0.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.
- checksums.yaml +4 -4
- data/ext/date/date_core.c +302 -90
- data/ext/date/date_parse.c +11 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e8e4c427833f2948ff528def0a31d95b84f1fa977afef755e9fb086ac8c84f
|
4
|
+
data.tar.gz: f0f4c810b24a50a1b3b6d766b34099b1dcecaee43bb0bac57c8ea818b2c8626d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5935548cb2bcf6eb8cb9f46275add4120033355c43c374722bc10be2cb30e90eedfae3333578687fa6a1ba2f10085ca83dea30fa32c3e75f3e347a770a203820
|
7
|
+
data.tar.gz: 11fd276dae330c4f6b437e9331b779875ac5ceb05929ab6204b04abcaed107e25421fc6ed32c5b4f58e884972318efef1bf761095a33cc32b1efedf5091ad320
|
data/ext/date/date_core.c
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
#include <sys/time.h>
|
12
12
|
#endif
|
13
13
|
|
14
|
+
#undef NDEBUG
|
14
15
|
#define NDEBUG
|
15
16
|
#include <assert.h>
|
16
17
|
|
@@ -4321,12 +4322,37 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
4321
4322
|
|
4322
4323
|
VALUE date__parse(VALUE str, VALUE comp);
|
4323
4324
|
|
4325
|
+
static size_t
|
4326
|
+
get_limit(VALUE opt)
|
4327
|
+
{
|
4328
|
+
if (!NIL_P(opt)) {
|
4329
|
+
VALUE limit = rb_hash_aref(opt, ID2SYM(rb_intern("limit")));
|
4330
|
+
if (NIL_P(limit)) return SIZE_MAX;
|
4331
|
+
return NUM2SIZET(limit);
|
4332
|
+
}
|
4333
|
+
return 128;
|
4334
|
+
}
|
4335
|
+
|
4336
|
+
static void
|
4337
|
+
check_limit(VALUE str, VALUE opt)
|
4338
|
+
{
|
4339
|
+
StringValue(str);
|
4340
|
+
size_t slen = RSTRING_LEN(str);
|
4341
|
+
size_t limit = get_limit(opt);
|
4342
|
+
if (slen > limit) {
|
4343
|
+
rb_raise(rb_eArgError,
|
4344
|
+
"string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
|
4345
|
+
}
|
4346
|
+
}
|
4347
|
+
|
4324
4348
|
static VALUE
|
4325
4349
|
date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
|
4326
4350
|
{
|
4327
|
-
VALUE vstr, vcomp, hash;
|
4351
|
+
VALUE vstr, vcomp, hash, opt;
|
4328
4352
|
|
4329
|
-
rb_scan_args(argc, argv, "11", &vstr, &vcomp);
|
4353
|
+
rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
|
4354
|
+
if (!NIL_P(opt)) argc--;
|
4355
|
+
check_limit(vstr, opt);
|
4330
4356
|
StringValue(vstr);
|
4331
4357
|
if (!rb_enc_str_asciicompat_p(vstr))
|
4332
4358
|
rb_raise(rb_eArgError,
|
@@ -4341,7 +4367,7 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
|
|
4341
4367
|
|
4342
4368
|
/*
|
4343
4369
|
* call-seq:
|
4344
|
-
* Date._parse(string[, comp=true]) -> hash
|
4370
|
+
* Date._parse(string[, comp=true], limit: 128) -> hash
|
4345
4371
|
*
|
4346
4372
|
* Parses the given representation of date and time, and returns a
|
4347
4373
|
* hash of parsed elements. This method does not function as a
|
@@ -4352,6 +4378,10 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
|
|
4352
4378
|
* it full.
|
4353
4379
|
*
|
4354
4380
|
* Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
|
4381
|
+
*
|
4382
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4383
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4384
|
+
* it may take a long time to parse.
|
4355
4385
|
*/
|
4356
4386
|
static VALUE
|
4357
4387
|
date_s__parse(int argc, VALUE *argv, VALUE klass)
|
@@ -4361,7 +4391,7 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
|
|
4361
4391
|
|
4362
4392
|
/*
|
4363
4393
|
* call-seq:
|
4364
|
-
* Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]) -> date
|
4394
|
+
* Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128) -> date
|
4365
4395
|
*
|
4366
4396
|
* Parses the given representation of date and time, and creates a
|
4367
4397
|
* date object. This method does not function as a validator.
|
@@ -4373,13 +4403,18 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
|
|
4373
4403
|
* Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
4374
4404
|
* Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
|
4375
4405
|
* Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
|
4406
|
+
*
|
4407
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4408
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4409
|
+
* it may take a long time to parse.
|
4376
4410
|
*/
|
4377
4411
|
static VALUE
|
4378
4412
|
date_s_parse(int argc, VALUE *argv, VALUE klass)
|
4379
4413
|
{
|
4380
|
-
VALUE str, comp, sg;
|
4414
|
+
VALUE str, comp, sg, opt;
|
4381
4415
|
|
4382
|
-
rb_scan_args(argc, argv, "03", &str, &comp, &sg);
|
4416
|
+
rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
|
4417
|
+
if (!NIL_P(opt)) argc--;
|
4383
4418
|
|
4384
4419
|
switch (argc) {
|
4385
4420
|
case 0:
|
@@ -4391,11 +4426,12 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
4391
4426
|
}
|
4392
4427
|
|
4393
4428
|
{
|
4394
|
-
|
4395
|
-
|
4396
|
-
|
4397
|
-
|
4398
|
-
|
4429
|
+
int argc2 = 2;
|
4430
|
+
VALUE argv2[3];
|
4431
|
+
argv2[0] = str;
|
4432
|
+
argv2[1] = comp;
|
4433
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4434
|
+
VALUE hash = date_s__parse(argc2, argv2, klass);
|
4399
4435
|
return d_new_by_frags(klass, hash, sg);
|
4400
4436
|
}
|
4401
4437
|
}
|
@@ -4409,19 +4445,28 @@ VALUE date__jisx0301(VALUE);
|
|
4409
4445
|
|
4410
4446
|
/*
|
4411
4447
|
* call-seq:
|
4412
|
-
* Date._iso8601(string) -> hash
|
4448
|
+
* Date._iso8601(string, limit: 128) -> hash
|
4413
4449
|
*
|
4414
4450
|
* Returns a hash of parsed elements.
|
4451
|
+
*
|
4452
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4453
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4454
|
+
* it may take a long time to parse.
|
4415
4455
|
*/
|
4416
4456
|
static VALUE
|
4417
|
-
date_s__iso8601(VALUE
|
4457
|
+
date_s__iso8601(int argc, VALUE *argv, VALUE klass)
|
4418
4458
|
{
|
4459
|
+
VALUE str, opt;
|
4460
|
+
|
4461
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4462
|
+
check_limit(str, opt);
|
4463
|
+
|
4419
4464
|
return date__iso8601(str);
|
4420
4465
|
}
|
4421
4466
|
|
4422
4467
|
/*
|
4423
4468
|
* call-seq:
|
4424
|
-
* Date.iso8601(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
4469
|
+
* Date.iso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
4425
4470
|
*
|
4426
4471
|
* Creates a new Date object by parsing from a string according to
|
4427
4472
|
* some typical ISO 8601 formats.
|
@@ -4429,13 +4474,18 @@ date_s__iso8601(VALUE klass, VALUE str)
|
|
4429
4474
|
* Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
4430
4475
|
* Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
|
4431
4476
|
* Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
|
4477
|
+
*
|
4478
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4479
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4480
|
+
* it may take a long time to parse.
|
4432
4481
|
*/
|
4433
4482
|
static VALUE
|
4434
4483
|
date_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
4435
4484
|
{
|
4436
|
-
VALUE str, sg;
|
4485
|
+
VALUE str, sg, opt;
|
4437
4486
|
|
4438
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4487
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4488
|
+
if (!NIL_P(opt)) argc--;
|
4439
4489
|
|
4440
4490
|
switch (argc) {
|
4441
4491
|
case 0:
|
@@ -4445,38 +4495,56 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
4445
4495
|
}
|
4446
4496
|
|
4447
4497
|
{
|
4448
|
-
|
4498
|
+
int argc2 = 1;
|
4499
|
+
VALUE argv2[2];
|
4500
|
+
argv2[0] = str;
|
4501
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4502
|
+
VALUE hash = date_s__iso8601(argc2, argv2, klass);
|
4449
4503
|
return d_new_by_frags(klass, hash, sg);
|
4450
4504
|
}
|
4451
4505
|
}
|
4452
4506
|
|
4453
4507
|
/*
|
4454
4508
|
* call-seq:
|
4455
|
-
* Date._rfc3339(string) -> hash
|
4509
|
+
* Date._rfc3339(string, limit: 128) -> hash
|
4456
4510
|
*
|
4457
4511
|
* Returns a hash of parsed elements.
|
4512
|
+
*
|
4513
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4514
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4515
|
+
* it may take a long time to parse.
|
4458
4516
|
*/
|
4459
4517
|
static VALUE
|
4460
|
-
date_s__rfc3339(VALUE
|
4518
|
+
date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
|
4461
4519
|
{
|
4520
|
+
VALUE str, opt;
|
4521
|
+
|
4522
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4523
|
+
check_limit(str, opt);
|
4524
|
+
|
4462
4525
|
return date__rfc3339(str);
|
4463
4526
|
}
|
4464
4527
|
|
4465
4528
|
/*
|
4466
4529
|
* call-seq:
|
4467
|
-
* Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> date
|
4530
|
+
* Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> date
|
4468
4531
|
*
|
4469
4532
|
* Creates a new Date object by parsing from a string according to
|
4470
4533
|
* some typical RFC 3339 formats.
|
4471
4534
|
*
|
4472
4535
|
* Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
|
4536
|
+
*
|
4537
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4538
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4539
|
+
* it may take a long time to parse.
|
4473
4540
|
*/
|
4474
4541
|
static VALUE
|
4475
4542
|
date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
4476
4543
|
{
|
4477
|
-
VALUE str, sg;
|
4544
|
+
VALUE str, sg, opt;
|
4478
4545
|
|
4479
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4546
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4547
|
+
if (!NIL_P(opt)) argc--;
|
4480
4548
|
|
4481
4549
|
switch (argc) {
|
4482
4550
|
case 0:
|
@@ -4486,38 +4554,56 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
4486
4554
|
}
|
4487
4555
|
|
4488
4556
|
{
|
4489
|
-
|
4557
|
+
int argc2 = 1;
|
4558
|
+
VALUE argv2[2];
|
4559
|
+
argv2[0] = str;
|
4560
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4561
|
+
VALUE hash = date_s__rfc3339(argc2, argv2, klass);
|
4490
4562
|
return d_new_by_frags(klass, hash, sg);
|
4491
4563
|
}
|
4492
4564
|
}
|
4493
4565
|
|
4494
4566
|
/*
|
4495
4567
|
* call-seq:
|
4496
|
-
* Date._xmlschema(string) -> hash
|
4568
|
+
* Date._xmlschema(string, limit: 128) -> hash
|
4497
4569
|
*
|
4498
4570
|
* Returns a hash of parsed elements.
|
4571
|
+
*
|
4572
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4573
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4574
|
+
* it may take a long time to parse.
|
4499
4575
|
*/
|
4500
4576
|
static VALUE
|
4501
|
-
date_s__xmlschema(VALUE
|
4577
|
+
date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
|
4502
4578
|
{
|
4579
|
+
VALUE str, opt;
|
4580
|
+
|
4581
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4582
|
+
check_limit(str, opt);
|
4583
|
+
|
4503
4584
|
return date__xmlschema(str);
|
4504
4585
|
}
|
4505
4586
|
|
4506
4587
|
/*
|
4507
4588
|
* call-seq:
|
4508
|
-
* Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
4589
|
+
* Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
4509
4590
|
*
|
4510
4591
|
* Creates a new Date object by parsing from a string according to
|
4511
4592
|
* some typical XML Schema formats.
|
4512
4593
|
*
|
4513
4594
|
* Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
4595
|
+
*
|
4596
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4597
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4598
|
+
* it may take a long time to parse.
|
4514
4599
|
*/
|
4515
4600
|
static VALUE
|
4516
4601
|
date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
4517
4602
|
{
|
4518
|
-
VALUE str, sg;
|
4603
|
+
VALUE str, sg, opt;
|
4519
4604
|
|
4520
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4605
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4606
|
+
if (!NIL_P(opt)) argc--;
|
4521
4607
|
|
4522
4608
|
switch (argc) {
|
4523
4609
|
case 0:
|
@@ -4527,41 +4613,58 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
4527
4613
|
}
|
4528
4614
|
|
4529
4615
|
{
|
4530
|
-
|
4616
|
+
int argc2 = 1;
|
4617
|
+
VALUE argv2[2];
|
4618
|
+
argv2[0] = str;
|
4619
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4620
|
+
VALUE hash = date_s__xmlschema(argc2, argv2, klass);
|
4531
4621
|
return d_new_by_frags(klass, hash, sg);
|
4532
4622
|
}
|
4533
4623
|
}
|
4534
4624
|
|
4535
4625
|
/*
|
4536
4626
|
* call-seq:
|
4537
|
-
* Date._rfc2822(string) -> hash
|
4538
|
-
* Date._rfc822(string) -> hash
|
4627
|
+
* Date._rfc2822(string, limit: 128) -> hash
|
4628
|
+
* Date._rfc822(string, limit: 128) -> hash
|
4539
4629
|
*
|
4540
4630
|
* Returns a hash of parsed elements.
|
4631
|
+
*
|
4632
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4633
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4634
|
+
* it may take a long time to parse.
|
4541
4635
|
*/
|
4542
4636
|
static VALUE
|
4543
|
-
date_s__rfc2822(VALUE
|
4637
|
+
date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
|
4544
4638
|
{
|
4639
|
+
VALUE str, opt;
|
4640
|
+
|
4641
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4642
|
+
check_limit(str, opt);
|
4643
|
+
|
4545
4644
|
return date__rfc2822(str);
|
4546
4645
|
}
|
4547
4646
|
|
4548
4647
|
/*
|
4549
4648
|
* call-seq:
|
4550
|
-
* Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
|
4551
|
-
* Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
|
4649
|
+
* Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
|
4650
|
+
* Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
|
4552
4651
|
*
|
4553
4652
|
* Creates a new Date object by parsing from a string according to
|
4554
4653
|
* some typical RFC 2822 formats.
|
4555
4654
|
*
|
4556
4655
|
* Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
|
4557
4656
|
* #=> #<Date: 2001-02-03 ...>
|
4657
|
+
*
|
4658
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4659
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4660
|
+
* it may take a long time to parse.
|
4558
4661
|
*/
|
4559
4662
|
static VALUE
|
4560
4663
|
date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
4561
4664
|
{
|
4562
|
-
VALUE str, sg;
|
4665
|
+
VALUE str, sg, opt;
|
4563
4666
|
|
4564
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4667
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4565
4668
|
|
4566
4669
|
switch (argc) {
|
4567
4670
|
case 0:
|
@@ -4571,39 +4674,56 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
4571
4674
|
}
|
4572
4675
|
|
4573
4676
|
{
|
4574
|
-
|
4677
|
+
int argc2 = 1;
|
4678
|
+
VALUE argv2[2];
|
4679
|
+
argv2[0] = str;
|
4680
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4681
|
+
VALUE hash = date_s__rfc2822(argc2, argv2, klass);
|
4575
4682
|
return d_new_by_frags(klass, hash, sg);
|
4576
4683
|
}
|
4577
4684
|
}
|
4578
4685
|
|
4579
4686
|
/*
|
4580
4687
|
* call-seq:
|
4581
|
-
* Date._httpdate(string) -> hash
|
4688
|
+
* Date._httpdate(string, limit: 128) -> hash
|
4582
4689
|
*
|
4583
4690
|
* Returns a hash of parsed elements.
|
4691
|
+
*
|
4692
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4693
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4694
|
+
* it may take a long time to parse.
|
4584
4695
|
*/
|
4585
4696
|
static VALUE
|
4586
|
-
date_s__httpdate(VALUE
|
4697
|
+
date_s__httpdate(int argc, VALUE *argv, VALUE klass)
|
4587
4698
|
{
|
4699
|
+
VALUE str, opt;
|
4700
|
+
|
4701
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4702
|
+
check_limit(str, opt);
|
4703
|
+
|
4588
4704
|
return date__httpdate(str);
|
4589
4705
|
}
|
4590
4706
|
|
4591
4707
|
/*
|
4592
4708
|
* call-seq:
|
4593
|
-
* Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) -> date
|
4709
|
+
* Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128) -> date
|
4594
4710
|
*
|
4595
4711
|
* Creates a new Date object by parsing from a string according to
|
4596
4712
|
* some RFC 2616 format.
|
4597
4713
|
*
|
4598
4714
|
* Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
|
4599
4715
|
* #=> #<Date: 2001-02-03 ...>
|
4716
|
+
*
|
4717
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4718
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4719
|
+
* it may take a long time to parse.
|
4600
4720
|
*/
|
4601
4721
|
static VALUE
|
4602
4722
|
date_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
4603
4723
|
{
|
4604
|
-
VALUE str, sg;
|
4724
|
+
VALUE str, sg, opt;
|
4605
4725
|
|
4606
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4726
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4607
4727
|
|
4608
4728
|
switch (argc) {
|
4609
4729
|
case 0:
|
@@ -4613,26 +4733,39 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
4613
4733
|
}
|
4614
4734
|
|
4615
4735
|
{
|
4616
|
-
|
4736
|
+
int argc2 = 1;
|
4737
|
+
VALUE argv2[2];
|
4738
|
+
argv2[0] = str;
|
4739
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4740
|
+
VALUE hash = date_s__httpdate(argc2, argv2, klass);
|
4617
4741
|
return d_new_by_frags(klass, hash, sg);
|
4618
4742
|
}
|
4619
4743
|
}
|
4620
4744
|
|
4621
4745
|
/*
|
4622
4746
|
* call-seq:
|
4623
|
-
* Date._jisx0301(string) -> hash
|
4747
|
+
* Date._jisx0301(string, limit: 128) -> hash
|
4624
4748
|
*
|
4625
4749
|
* Returns a hash of parsed elements.
|
4750
|
+
*
|
4751
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4752
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4753
|
+
* it may take a long time to parse.
|
4626
4754
|
*/
|
4627
4755
|
static VALUE
|
4628
|
-
date_s__jisx0301(VALUE
|
4756
|
+
date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
|
4629
4757
|
{
|
4758
|
+
VALUE str, opt;
|
4759
|
+
|
4760
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4761
|
+
check_limit(str, opt);
|
4762
|
+
|
4630
4763
|
return date__jisx0301(str);
|
4631
4764
|
}
|
4632
4765
|
|
4633
4766
|
/*
|
4634
4767
|
* call-seq:
|
4635
|
-
* Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
4768
|
+
* Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
4636
4769
|
*
|
4637
4770
|
* Creates a new Date object by parsing from a string according to
|
4638
4771
|
* some typical JIS X 0301 formats.
|
@@ -4642,13 +4775,18 @@ date_s__jisx0301(VALUE klass, VALUE str)
|
|
4642
4775
|
* For no-era year, legacy format, Heisei is assumed.
|
4643
4776
|
*
|
4644
4777
|
* Date.jisx0301('13.02.03') #=> #<Date: 2001-02-03 ...>
|
4778
|
+
*
|
4779
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4780
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4781
|
+
* it may take a long time to parse.
|
4645
4782
|
*/
|
4646
4783
|
static VALUE
|
4647
4784
|
date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
4648
4785
|
{
|
4649
|
-
VALUE str, sg;
|
4786
|
+
VALUE str, sg, opt;
|
4650
4787
|
|
4651
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4788
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4789
|
+
if (!NIL_P(opt)) argc--;
|
4652
4790
|
|
4653
4791
|
switch (argc) {
|
4654
4792
|
case 0:
|
@@ -4658,7 +4796,11 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
4658
4796
|
}
|
4659
4797
|
|
4660
4798
|
{
|
4661
|
-
|
4799
|
+
int argc2 = 1;
|
4800
|
+
VALUE argv2[2];
|
4801
|
+
argv2[0] = str;
|
4802
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4803
|
+
VALUE hash = date_s__jisx0301(argc2, argv2, klass);
|
4662
4804
|
return d_new_by_frags(klass, hash, sg);
|
4663
4805
|
}
|
4664
4806
|
}
|
@@ -7201,11 +7343,14 @@ d_lite_marshal_load(VALUE self, VALUE a)
|
|
7201
7343
|
|
7202
7344
|
if (simple_dat_p(dat)) {
|
7203
7345
|
if (df || !f_zero_p(sf) || of) {
|
7204
|
-
|
7205
|
-
|
7346
|
+
/* loading a fractional date; promote to complex */
|
7347
|
+
dat = ruby_xrealloc(dat, sizeof(struct ComplexDateData));
|
7348
|
+
RTYPEDDATA(self)->data = dat;
|
7349
|
+
goto complex_data;
|
7206
7350
|
}
|
7207
7351
|
set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
|
7208
7352
|
} else {
|
7353
|
+
complex_data:
|
7209
7354
|
set_to_complex(self, &dat->c, nth, jd, df, sf, of, sg,
|
7210
7355
|
0, 0, 0, 0, 0, 0,
|
7211
7356
|
HAVE_JD | HAVE_DF);
|
@@ -7994,7 +8139,7 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
7994
8139
|
|
7995
8140
|
/*
|
7996
8141
|
* call-seq:
|
7997
|
-
* DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]) -> datetime
|
8142
|
+
* DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]], limit: 128) -> datetime
|
7998
8143
|
*
|
7999
8144
|
* Parses the given representation of date and time, and creates a
|
8000
8145
|
* DateTime object. This method does not function as a validator.
|
@@ -8008,13 +8153,18 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
8008
8153
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8009
8154
|
* DateTime.parse('3rd Feb 2001 04:05:06 PM')
|
8010
8155
|
* #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
|
8156
|
+
*
|
8157
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8158
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8159
|
+
* it may take a long time to parse.
|
8011
8160
|
*/
|
8012
8161
|
static VALUE
|
8013
8162
|
datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
8014
8163
|
{
|
8015
|
-
VALUE str, comp, sg;
|
8164
|
+
VALUE str, comp, sg, opt;
|
8016
8165
|
|
8017
|
-
rb_scan_args(argc, argv, "03", &str, &comp, &sg);
|
8166
|
+
rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
|
8167
|
+
if (!NIL_P(opt)) argc--;
|
8018
8168
|
|
8019
8169
|
switch (argc) {
|
8020
8170
|
case 0:
|
@@ -8026,18 +8176,20 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
8026
8176
|
}
|
8027
8177
|
|
8028
8178
|
{
|
8029
|
-
|
8030
|
-
|
8031
|
-
|
8032
|
-
|
8033
|
-
|
8179
|
+
int argc2 = 2;
|
8180
|
+
VALUE argv2[3];
|
8181
|
+
argv2[0] = str;
|
8182
|
+
argv2[1] = comp;
|
8183
|
+
argv2[2] = opt;
|
8184
|
+
if (!NIL_P(opt)) argc2++;
|
8185
|
+
VALUE hash = date_s__parse(argc2, argv2, klass);
|
8034
8186
|
return dt_new_by_frags(klass, hash, sg);
|
8035
8187
|
}
|
8036
8188
|
}
|
8037
8189
|
|
8038
8190
|
/*
|
8039
8191
|
* call-seq:
|
8040
|
-
* DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8192
|
+
* DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8041
8193
|
*
|
8042
8194
|
* Creates a new DateTime object by parsing from a string according to
|
8043
8195
|
* some typical ISO 8601 formats.
|
@@ -8048,13 +8200,18 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
8048
8200
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8049
8201
|
* DateTime.iso8601('2001-W05-6T04:05:06+07:00')
|
8050
8202
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8203
|
+
*
|
8204
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8205
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8206
|
+
* it may take a long time to parse.
|
8051
8207
|
*/
|
8052
8208
|
static VALUE
|
8053
8209
|
datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
8054
8210
|
{
|
8055
|
-
VALUE str, sg;
|
8211
|
+
VALUE str, sg, opt;
|
8056
8212
|
|
8057
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8213
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8214
|
+
if (!NIL_P(opt)) argc--;
|
8058
8215
|
|
8059
8216
|
switch (argc) {
|
8060
8217
|
case 0:
|
@@ -8064,27 +8221,37 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
8064
8221
|
}
|
8065
8222
|
|
8066
8223
|
{
|
8067
|
-
|
8224
|
+
int argc2 = 1;
|
8225
|
+
VALUE argv2[2];
|
8226
|
+
argv2[0] = str;
|
8227
|
+
argv2[1] = opt;
|
8228
|
+
if (!NIL_P(opt)) argc2--;
|
8229
|
+
VALUE hash = date_s__iso8601(argc2, argv2, klass);
|
8068
8230
|
return dt_new_by_frags(klass, hash, sg);
|
8069
8231
|
}
|
8070
8232
|
}
|
8071
8233
|
|
8072
8234
|
/*
|
8073
8235
|
* call-seq:
|
8074
|
-
* DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8236
|
+
* DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8075
8237
|
*
|
8076
8238
|
* Creates a new DateTime object by parsing from a string according to
|
8077
8239
|
* some typical RFC 3339 formats.
|
8078
8240
|
*
|
8079
8241
|
* DateTime.rfc3339('2001-02-03T04:05:06+07:00')
|
8080
8242
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8243
|
+
*
|
8244
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8245
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8246
|
+
* it may take a long time to parse.
|
8081
8247
|
*/
|
8082
8248
|
static VALUE
|
8083
8249
|
datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
8084
8250
|
{
|
8085
|
-
VALUE str, sg;
|
8251
|
+
VALUE str, sg, opt;
|
8086
8252
|
|
8087
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8253
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8254
|
+
if (!NIL_P(opt)) argc--;
|
8088
8255
|
|
8089
8256
|
switch (argc) {
|
8090
8257
|
case 0:
|
@@ -8094,27 +8261,37 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
8094
8261
|
}
|
8095
8262
|
|
8096
8263
|
{
|
8097
|
-
|
8264
|
+
int argc2 = 1;
|
8265
|
+
VALUE argv2[2];
|
8266
|
+
argv2[0] = str;
|
8267
|
+
argv2[1] = opt;
|
8268
|
+
if (!NIL_P(opt)) argc2++;
|
8269
|
+
VALUE hash = date_s__rfc3339(argc2, argv2, klass);
|
8098
8270
|
return dt_new_by_frags(klass, hash, sg);
|
8099
8271
|
}
|
8100
8272
|
}
|
8101
8273
|
|
8102
8274
|
/*
|
8103
8275
|
* call-seq:
|
8104
|
-
* DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8276
|
+
* DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8105
8277
|
*
|
8106
8278
|
* Creates a new DateTime object by parsing from a string according to
|
8107
8279
|
* some typical XML Schema formats.
|
8108
8280
|
*
|
8109
8281
|
* DateTime.xmlschema('2001-02-03T04:05:06+07:00')
|
8110
8282
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8283
|
+
*
|
8284
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8285
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8286
|
+
* it may take a long time to parse.
|
8111
8287
|
*/
|
8112
8288
|
static VALUE
|
8113
8289
|
datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
8114
8290
|
{
|
8115
|
-
VALUE str, sg;
|
8291
|
+
VALUE str, sg, opt;
|
8116
8292
|
|
8117
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8293
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8294
|
+
if (!NIL_P(opt)) argc--;
|
8118
8295
|
|
8119
8296
|
switch (argc) {
|
8120
8297
|
case 0:
|
@@ -8124,28 +8301,38 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
8124
8301
|
}
|
8125
8302
|
|
8126
8303
|
{
|
8127
|
-
|
8304
|
+
int argc2 = 1;
|
8305
|
+
VALUE argv2[2];
|
8306
|
+
argv2[0] = str;
|
8307
|
+
argv2[1] = opt;
|
8308
|
+
if (!NIL_P(opt)) argc2++;
|
8309
|
+
VALUE hash = date_s__xmlschema(argc2, argv2, klass);
|
8128
8310
|
return dt_new_by_frags(klass, hash, sg);
|
8129
8311
|
}
|
8130
8312
|
}
|
8131
8313
|
|
8132
8314
|
/*
|
8133
8315
|
* call-seq:
|
8134
|
-
* DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
|
8135
|
-
* DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
|
8316
|
+
* DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
|
8317
|
+
* DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
|
8136
8318
|
*
|
8137
8319
|
* Creates a new DateTime object by parsing from a string according to
|
8138
8320
|
* some typical RFC 2822 formats.
|
8139
8321
|
*
|
8140
8322
|
* DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
|
8141
8323
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8324
|
+
*
|
8325
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8326
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8327
|
+
* it may take a long time to parse.
|
8142
8328
|
*/
|
8143
8329
|
static VALUE
|
8144
8330
|
datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
8145
8331
|
{
|
8146
|
-
VALUE str, sg;
|
8332
|
+
VALUE str, sg, opt;
|
8147
8333
|
|
8148
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8334
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8335
|
+
if (!NIL_P(opt)) argc--;
|
8149
8336
|
|
8150
8337
|
switch (argc) {
|
8151
8338
|
case 0:
|
@@ -8155,7 +8342,12 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
8155
8342
|
}
|
8156
8343
|
|
8157
8344
|
{
|
8158
|
-
|
8345
|
+
int argc2 = 1;
|
8346
|
+
VALUE argv2[2];
|
8347
|
+
argv2[0] = str;
|
8348
|
+
argv2[1] = opt;
|
8349
|
+
if (!NIL_P(opt)) argc2++;
|
8350
|
+
VALUE hash = date_s__rfc2822(argc2, argv2, klass);
|
8159
8351
|
return dt_new_by_frags(klass, hash, sg);
|
8160
8352
|
}
|
8161
8353
|
}
|
@@ -8169,13 +8361,18 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
8169
8361
|
*
|
8170
8362
|
* DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
|
8171
8363
|
* #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
|
8364
|
+
*
|
8365
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8366
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8367
|
+
* it may take a long time to parse.
|
8172
8368
|
*/
|
8173
8369
|
static VALUE
|
8174
8370
|
datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
8175
8371
|
{
|
8176
|
-
VALUE str, sg;
|
8372
|
+
VALUE str, sg, opt;
|
8177
8373
|
|
8178
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8374
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8375
|
+
if (!NIL_P(opt)) argc--;
|
8179
8376
|
|
8180
8377
|
switch (argc) {
|
8181
8378
|
case 0:
|
@@ -8185,14 +8382,19 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
8185
8382
|
}
|
8186
8383
|
|
8187
8384
|
{
|
8188
|
-
|
8385
|
+
int argc2 = 1;
|
8386
|
+
VALUE argv2[2];
|
8387
|
+
argv2[0] = str;
|
8388
|
+
argv2[1] = opt;
|
8389
|
+
if (!NIL_P(opt)) argc2++;
|
8390
|
+
VALUE hash = date_s__httpdate(argc2, argv2, klass);
|
8189
8391
|
return dt_new_by_frags(klass, hash, sg);
|
8190
8392
|
}
|
8191
8393
|
}
|
8192
8394
|
|
8193
8395
|
/*
|
8194
8396
|
* call-seq:
|
8195
|
-
* DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8397
|
+
* DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8196
8398
|
*
|
8197
8399
|
* Creates a new DateTime object by parsing from a string according to
|
8198
8400
|
* some typical JIS X 0301 formats.
|
@@ -8204,13 +8406,18 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
8204
8406
|
*
|
8205
8407
|
* DateTime.jisx0301('13.02.03T04:05:06+07:00')
|
8206
8408
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8409
|
+
*
|
8410
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8411
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8412
|
+
* it may take a long time to parse.
|
8207
8413
|
*/
|
8208
8414
|
static VALUE
|
8209
8415
|
datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
8210
8416
|
{
|
8211
|
-
VALUE str, sg;
|
8417
|
+
VALUE str, sg, opt;
|
8212
8418
|
|
8213
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8419
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8420
|
+
if (!NIL_P(opt)) argc--;
|
8214
8421
|
|
8215
8422
|
switch (argc) {
|
8216
8423
|
case 0:
|
@@ -8220,7 +8427,12 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
8220
8427
|
}
|
8221
8428
|
|
8222
8429
|
{
|
8223
|
-
|
8430
|
+
int argc2 = 1;
|
8431
|
+
VALUE argv2[2];
|
8432
|
+
argv2[0] = str;
|
8433
|
+
argv2[1] = opt;
|
8434
|
+
if (!NIL_P(opt)) argc2++;
|
8435
|
+
VALUE hash = date_s__jisx0301(argc2, argv2, klass);
|
8224
8436
|
return dt_new_by_frags(klass, hash, sg);
|
8225
8437
|
}
|
8226
8438
|
}
|
@@ -9379,19 +9591,19 @@ Init_date_core(void)
|
|
9379
9591
|
rb_define_singleton_method(cDate, "strptime", date_s_strptime, -1);
|
9380
9592
|
rb_define_singleton_method(cDate, "_parse", date_s__parse, -1);
|
9381
9593
|
rb_define_singleton_method(cDate, "parse", date_s_parse, -1);
|
9382
|
-
rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, 1);
|
9594
|
+
rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, -1);
|
9383
9595
|
rb_define_singleton_method(cDate, "iso8601", date_s_iso8601, -1);
|
9384
|
-
rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, 1);
|
9596
|
+
rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, -1);
|
9385
9597
|
rb_define_singleton_method(cDate, "rfc3339", date_s_rfc3339, -1);
|
9386
|
-
rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, 1);
|
9598
|
+
rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, -1);
|
9387
9599
|
rb_define_singleton_method(cDate, "xmlschema", date_s_xmlschema, -1);
|
9388
|
-
rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, 1);
|
9389
|
-
rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, 1);
|
9600
|
+
rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, -1);
|
9601
|
+
rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, -1);
|
9390
9602
|
rb_define_singleton_method(cDate, "rfc2822", date_s_rfc2822, -1);
|
9391
9603
|
rb_define_singleton_method(cDate, "rfc822", date_s_rfc2822, -1);
|
9392
|
-
rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, 1);
|
9604
|
+
rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, -1);
|
9393
9605
|
rb_define_singleton_method(cDate, "httpdate", date_s_httpdate, -1);
|
9394
|
-
rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, 1);
|
9606
|
+
rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, -1);
|
9395
9607
|
rb_define_singleton_method(cDate, "jisx0301", date_s_jisx0301, -1);
|
9396
9608
|
|
9397
9609
|
rb_define_method(cDate, "initialize", date_initialize, -1);
|
data/ext/date/date_parse.c
CHANGED
@@ -70,7 +70,7 @@ static size_t
|
|
70
70
|
digit_span(const char *s, const char *e)
|
71
71
|
{
|
72
72
|
size_t i = 0;
|
73
|
-
while (s + i < e && isdigit(s[i])) i++;
|
73
|
+
while (s + i < e && isdigit((unsigned char)s[i])) i++;
|
74
74
|
return i;
|
75
75
|
}
|
76
76
|
|
@@ -110,7 +110,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
|
|
110
110
|
|
111
111
|
s = RSTRING_PTR(y);
|
112
112
|
ep = RSTRING_END(y);
|
113
|
-
while (s < ep && !issign(*s) && !isdigit(*s))
|
113
|
+
while (s < ep && !issign(*s) && !isdigit((unsigned char)*s))
|
114
114
|
s++;
|
115
115
|
if (s >= ep) goto no_date;
|
116
116
|
bp = s;
|
@@ -162,7 +162,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
|
|
162
162
|
|
163
163
|
s = RSTRING_PTR(y);
|
164
164
|
ep = RSTRING_END(y);
|
165
|
-
while (s < ep && !issign(*s) && !isdigit(*s))
|
165
|
+
while (s < ep && !issign(*s) && !isdigit((unsigned char)*s))
|
166
166
|
s++;
|
167
167
|
if (s >= ep) goto no_year;
|
168
168
|
bp = s;
|
@@ -199,7 +199,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
|
|
199
199
|
|
200
200
|
s = RSTRING_PTR(m);
|
201
201
|
ep = RSTRING_END(m);
|
202
|
-
while (s < ep && !isdigit(*s))
|
202
|
+
while (s < ep && !isdigit((unsigned char)*s))
|
203
203
|
s++;
|
204
204
|
if (s >= ep) goto no_month;
|
205
205
|
bp = s;
|
@@ -225,7 +225,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
|
|
225
225
|
|
226
226
|
s = RSTRING_PTR(d);
|
227
227
|
ep = RSTRING_END(d);
|
228
|
-
while (s < ep && !isdigit(*s))
|
228
|
+
while (s < ep && !isdigit((unsigned char)*s))
|
229
229
|
s++;
|
230
230
|
if (s >= ep) goto no_mday;
|
231
231
|
bp = s;
|
@@ -364,9 +364,9 @@ static int
|
|
364
364
|
str_end_with_word(const char *s, long l, const char *w)
|
365
365
|
{
|
366
366
|
int n = (int)strlen(w);
|
367
|
-
if (l <= n || !isspace(s[l - n - 1])) return 0;
|
367
|
+
if (l <= n || !isspace((unsigned char)s[l - n - 1])) return 0;
|
368
368
|
if (strncasecmp(&s[l - n], w, n)) return 0;
|
369
|
-
do ++n; while (l > n && isspace(s[l - n - 1]));
|
369
|
+
do ++n; while (l > n && isspace((unsigned char)s[l - n - 1]));
|
370
370
|
return n;
|
371
371
|
}
|
372
372
|
|
@@ -376,7 +376,7 @@ shrunk_size(const char *s, long l)
|
|
376
376
|
long i, ni;
|
377
377
|
int sp = 0;
|
378
378
|
for (i = ni = 0; i < l; ++i) {
|
379
|
-
if (!isspace(s[i])) {
|
379
|
+
if (!isspace((unsigned char)s[i])) {
|
380
380
|
if (sp) ni++;
|
381
381
|
sp = 0;
|
382
382
|
ni++;
|
@@ -394,7 +394,7 @@ shrink_space(char *d, const char *s, long l)
|
|
394
394
|
long i, ni;
|
395
395
|
int sp = 0;
|
396
396
|
for (i = ni = 0; i < l; ++i) {
|
397
|
-
if (!isspace(s[i])) {
|
397
|
+
if (!isspace((unsigned char)s[i])) {
|
398
398
|
if (sp) d[ni++] = ' ';
|
399
399
|
sp = 0;
|
400
400
|
d[ni++] = s[i];
|
@@ -754,8 +754,8 @@ check_year_width(VALUE y)
|
|
754
754
|
l = RSTRING_LEN(y);
|
755
755
|
if (l < 2) return 0;
|
756
756
|
s = RSTRING_PTR(y);
|
757
|
-
if (!isdigit(s[1])) return 0;
|
758
|
-
return (l == 2 || !isdigit(s[2]));
|
757
|
+
if (!isdigit((unsigned char)s[1])) return 0;
|
758
|
+
return (l == 2 || !isdigit((unsigned char)s[2]));
|
759
759
|
}
|
760
760
|
|
761
761
|
static int
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadayoshi Funaba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A subclass of Object includes Comparable module for handling dates.
|
14
14
|
email:
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
|
-
rubygems_version: 3.
|
50
|
+
rubygems_version: 3.1.4
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: A subclass of Object includes Comparable module for handling dates.
|