forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.hpp
76 lines (55 loc) · 1.8 KB
/
time.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef RBX_BUILTIN_TIME_HPP
#define RBX_BUILTIN_TIME_HPP
#include "builtin/object.hpp"
#include "type_info.hpp"
#include "builtin/tuple.hpp"
#include "builtin/integer.hpp"
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
# define HAVE_STRUCT_TM_TM_GMTOFF
# define HAVE_STRUCT_TM_TM_ZONE
#endif
namespace rubinius {
class Array;
class String;
typedef time_t int64_t;
class Time : public Object {
public:
const static object_type type = TimeType;
private:
time_t seconds_;
time_t microseconds_;
Array* decomposed_; // slot
Object* is_gmt_; // slot
public:
/* accessors */
attr_accessor(decomposed, Array);
attr_accessor(is_gmt, Object);
/* interface */
static void init(STATE);
// Rubinius.primitive :time_s_specific
static Time* specific(STATE, Object* self, Integer* sec, Integer* usec, Object* gmt);
// Rubinius.primitive :time_s_now
static Time* now(STATE, Object* self);
// Rubinius.primitive :time_s_from_array
static Time* from_array(STATE, Object* self, Fixnum* sec, Fixnum* min, Fixnum* hour, Fixnum* mday, Fixnum* mon, Fixnum* year, Fixnum* usec, Fixnum* isdst, Object* from_gmt);
// Rubinius.primitive :time_dup
Time* dup(STATE);
// Rubinius.primitive :time_seconds
Integer* seconds(STATE) {
return Integer::from(state, seconds_);
}
// Rubinius.primitive :time_useconds
Integer* useconds(STATE) {
return Integer::from(state, microseconds_);
}
// Rubinius.primitive :time_decompose
Array* calculate_decompose(STATE, Object* gmt);
// Rubinius.primitive :time_strftime
String* strftime(STATE, String* format);
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
};
};
};
#endif