Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
f8ab3c1e
Unverified
Commit
f8ab3c1e
authored
7 years ago
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
7 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3932 from ken-mu/timegm
mruby-time: Fix mruby specific timegm() cannot return minus
parents
e5fb21b6
d398cd47
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
+8
-2
mrbgems/mruby-time/test/time.rb
mrbgems/mruby-time/test/time.rb
+8
-0
No files found.
mrbgems/mruby-time/src/time.c
View file @
f8ab3c1e
...
...
@@ -138,8 +138,14 @@ timegm(struct tm *tm)
int
i
;
unsigned
int
*
nday
=
(
unsigned
int
*
)
ndays
[
is_leapyear
(
tm
->
tm_year
+
1900
)];
for
(
i
=
70
;
i
<
tm
->
tm_year
;
++
i
)
static
const
int
epoch_year
=
70
;
if
(
tm
->
tm_year
>=
epoch_year
)
{
for
(
i
=
epoch_year
;
i
<
tm
->
tm_year
;
++
i
)
r
+=
is_leapyear
(
i
+
1900
)
?
366
*
24
*
60
*
60
:
365
*
24
*
60
*
60
;
}
else
{
for
(
i
=
tm
->
tm_year
;
i
<
epoch_year
;
++
i
)
r
-=
is_leapyear
(
i
+
1900
)
?
366
*
24
*
60
*
60
:
365
*
24
*
60
*
60
;
}
for
(
i
=
0
;
i
<
tm
->
tm_mon
;
++
i
)
r
+=
nday
[
i
]
*
24
*
60
*
60
;
r
+=
(
tm
->
tm_mday
-
1
)
*
24
*
60
*
60
;
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-time/test/time.rb
View file @
f8ab3c1e
...
...
@@ -226,3 +226,11 @@ assert('2000 times 500us make a second') do
end
t
.
usec
==
0
end
assert
(
'Time.new with Dec 31 23:59:59 1969 raise ArgumentError'
)
do
assert_raise
(
ArgumentError
)
{
Time
.
new
(
1969
,
12
,
31
,
23
,
59
,
59
)}
end
assert
(
'Time.gm with Dec 31 23:59:59 1969 raise ArgumentError'
)
do
assert_raise
(
ArgumentError
)
{
Time
.
gm
(
1969
,
12
,
31
,
23
,
59
,
59
)}
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment