Skip to content

Commit a46ce21

Browse files
author
livecodeali
committed
[[ DateTime ]] Adjust date values so they are as documented
1 parent 1d1b50f commit a46ce21

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/lcb/notes/16681.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# LiveCode Builder Host Library
2+
3+
## Local date
4+
The date items are now adjusted so that the year and month are absolute
5+
rather than offsets from 1900 and January respectively.
6+
7+
# [16681] Returned date is not as documented

libscript/src/module-date.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ MCDateExecGetDate(bool t_is_local,
125125
return;
126126
}
127127

128+
// tm_mon is number of months since January
129+
t_timeinfo . tm_mon++;
130+
131+
// tm_year is number of years since 1900
132+
t_timeinfo . tm_year += 1900;
133+
128134
MCAutoNumberRef t_year, t_month, t_day, t_hour, t_minute, t_second,
129135
t_gmtoff;
130136
if (!(MCNumberCreateWithInteger (t_timeinfo.tm_year, &t_year) &&

0 commit comments

Comments
 (0)