]> granicus.if.org Git - icinga2/blob - lib/base/datetime-script.cpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / base / datetime-script.cpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #include "base/datetime.hpp"
4 #include "base/function.hpp"
5 #include "base/functionwrapper.hpp"
6 #include "base/scriptframe.hpp"
7 #include "base/objectlock.hpp"
8
9 using namespace icinga;
10
11 static String DateTimeFormat(const String& format)
12 {
13         ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
14         DateTime::Ptr self = static_cast<DateTime::Ptr>(vframe->Self);
15         REQUIRE_NOT_NULL(self);
16
17         return self->Format(format);
18 }
19
20 Object::Ptr DateTime::GetPrototype()
21 {
22         static Dictionary::Ptr prototype = new Dictionary({
23                 { "format", new Function("DateTime#format", DateTimeFormat, { "format" }) }
24         });
25
26         return prototype;
27 }
28