Skip to content

Commit 1828ae1

Browse files
author
Arnaud Bouchez
committed
ex: let MVC sample use the new MONTH_NAMES[] constant
1 parent ac0c99a commit 1828ae1

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

ex/mvc-blog/MVCViewModel.pas

+7-18
Original file line numberDiff line numberDiff line change
@@ -191,26 +191,15 @@ procedure TBlogApplication.Start(aServer: TRest; const aTemplatesFolder: TFileNa
191191
end;
192192

193193
procedure TBlogApplication.MonthToText(const Value: variant; out result: variant);
194-
const
195-
MONTHS: array[0..11] of RawUtf8 = (
196-
'January',
197-
'February',
198-
'March',
199-
'April',
200-
'May',
201-
'June',
202-
'July',
203-
'August',
204-
'September',
205-
'October',
206-
'November',
207-
'December');
208194
var
209-
month: integer;
195+
m, y: integer;
210196
begin
211-
if VariantToInteger(Value, month) and
212-
(month > 0) then
213-
RawUtf8ToVariant(MONTHS[month mod 12] + ' ' + UInt32ToUTF8(month div 12), result)
197+
if VariantToInteger(Value, m) and
198+
(m > 0) then
199+
begin
200+
y := m div 12;
201+
RawUtf8ToVariant(Make([MONTH_NAMES[m - y * 12 + 1], ' ', y]), result);
202+
end
214203
else
215204
SetVariantNull(result);
216205
end;

src/mormot.commit.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.3.10363'
1+
'2.3.10364'

0 commit comments

Comments
 (0)