Debian Codegraph @

query_time.go

raw symbols SCIP
1 package rethinkdb
2
3 import (
4 p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2"
5 )
6
7 // Now returns a time object representing the current time in UTC
8 func Now(args ...interface{}) Term {
9 return constructRootTerm("Now", p.Term_NOW, args, map[string]interface{}{})
10 }
11
12 // Time creates a time object for a specific time
13 func Time(args ...interface{}) Term {
14 return constructRootTerm("Time", p.Term_TIME, args, map[string]interface{}{})
15 }
16
17 // EpochTime returns a time object based on seconds since epoch
18 func EpochTime(args ...interface{}) Term {
19 return constructRootTerm("EpochTime", p.Term_EPOCH_TIME, args, map[string]interface{}{})
20 }
21
22 // ISO8601Opts contains the optional arguments for the ISO8601 term
23 type ISO8601Opts struct {
24 DefaultTimezone interface{} `rethinkdb:"default_timezone,omitempty"`
25 }
26
27 func (o ISO8601Opts) toMap() map[string]interface{} {
28 return optArgsToMap(o)
29 }
30
31 // ISO8601 returns a time object based on an ISO8601 formatted date-time string
32 func ISO8601(date interface{}, optArgs ...ISO8601Opts) Term {
33
34 opts := map[string]interface{}{}
35 if len(optArgs) >= 1 {
36 opts = optArgs[0].toMap()
37 }
38 return constructRootTerm("ISO8601", p.Term_ISO8601, []interface{}{date}, opts)
39 }
40
41 // InTimezone returns a new time object with a different time zone. While the
42 // time stays the same, the results returned by methods such as hours() will
43 // change since they take the timezone into account. The timezone argument
44 // has to be of the ISO 8601 format.
45 func (t Term) InTimezone(args ...interface{}) Term {
46 return constructMethodTerm(t, "InTimezone", p.Term_IN_TIMEZONE, args, map[string]interface{}{})
47 }
48
49 // Timezone returns the timezone of the time object
50 func (t Term) Timezone(args ...interface{}) Term {
51 return constructMethodTerm(t, "Timezone", p.Term_TIMEZONE, args, map[string]interface{}{})
52 }
53
54 // DuringOpts contains the optional arguments for the During term
55 type DuringOpts struct {
56 LeftBound interface{} `rethinkdb:"left_bound,omitempty"`
57 RightBound interface{} `rethinkdb:"right_bound,omitempty"`
58 }
59
60 func (o DuringOpts) toMap() map[string]interface{} {
61 return optArgsToMap(o)
62 }
63
64 // During returns true if a time is between two other times
65 // (by default, inclusive for the start, exclusive for the end).
66 func (t Term) During(startTime, endTime interface{}, optArgs ...DuringOpts) Term {
67 opts := map[string]interface{}{}
68 if len(optArgs) >= 1 {
69 opts = optArgs[0].toMap()
70 }
71 return constructMethodTerm(t, "During", p.Term_DURING, []interface{}{startTime, endTime}, opts)
72 }
73
74 // Date returns a new time object only based on the day, month and year
75 // (ie. the same day at 00:00).
76 func (t Term) Date(args ...interface{}) Term {
77 return constructMethodTerm(t, "Date", p.Term_DATE, args, map[string]interface{}{})
78 }
79
80 // TimeOfDay returns the number of seconds elapsed since the beginning of the
81 // day stored in the time object.
82 func (t Term) TimeOfDay(args ...interface{}) Term {
83 return constructMethodTerm(t, "TimeOfDay", p.Term_TIME_OF_DAY, args, map[string]interface{}{})
84 }
85
86 // Year returns the year of a time object.
87 func (t Term) Year(args ...interface{}) Term {
88 return constructMethodTerm(t, "Year", p.Term_YEAR, args, map[string]interface{}{})
89 }
90
91 // Month returns the month of a time object as a number between 1 and 12.
92 // For your convenience, the terms r.January(), r.February() etc. are
93 // defined and map to the appropriate integer.
94 func (t Term) Month(args ...interface{}) Term {
95 return constructMethodTerm(t, "Month", p.Term_MONTH, args, map[string]interface{}{})
96 }
97
98 // Day return the day of a time object as a number between 1 and 31.
99 func (t Term) Day(args ...interface{}) Term {
100 return constructMethodTerm(t, "Day", p.Term_DAY, args, map[string]interface{}{})
101 }
102
103 // DayOfWeek returns the day of week of a time object as a number between
104 // 1 and 7 (following ISO 8601 standard). For your convenience,
105 // the terms r.Monday(), r.Tuesday() etc. are defined and map to
106 // the appropriate integer.
107 func (t Term) DayOfWeek(args ...interface{}) Term {
108 return constructMethodTerm(t, "DayOfWeek", p.Term_DAY_OF_WEEK, args, map[string]interface{}{})
109 }
110
111 // DayOfYear returns the day of the year of a time object as a number between
112 // 1 and 366 (following ISO 8601 standard).
113 func (t Term) DayOfYear(args ...interface{}) Term {
114 return constructMethodTerm(t, "DayOfYear", p.Term_DAY_OF_YEAR, args, map[string]interface{}{})
115 }
116
117 // Hours returns the hour in a time object as a number between 0 and 23.
118 func (t Term) Hours(args ...interface{}) Term {
119 return constructMethodTerm(t, "Hours", p.Term_HOURS, args, map[string]interface{}{})
120 }
121
122 // Minutes returns the minute in a time object as a number between 0 and 59.
123 func (t Term) Minutes(args ...interface{}) Term {
124 return constructMethodTerm(t, "Minutes", p.Term_MINUTES, args, map[string]interface{}{})
125 }
126
127 // Seconds returns the seconds in a time object as a number between 0 and
128 // 59.999 (double precision).
129 func (t Term) Seconds(args ...interface{}) Term {
130 return constructMethodTerm(t, "Seconds", p.Term_SECONDS, args, map[string]interface{}{})
131 }
132
133 // ToISO8601 converts a time object to its iso 8601 format.
134 func (t Term) ToISO8601(args ...interface{}) Term {
135 return constructMethodTerm(t, "ToISO8601", p.Term_TO_ISO8601, args, map[string]interface{}{})
136 }
137
138 // ToEpochTime converts a time object to its epoch time.
139 func (t Term) ToEpochTime(args ...interface{}) Term {
140 return constructMethodTerm(t, "ToEpochTime", p.Term_TO_EPOCH_TIME, args, map[string]interface{}{})
141 }
142
143 var (
144 // Days
145
146 // Monday is a constant representing the day of the week Monday
147 Monday = constructRootTerm("Monday", p.Term_MONDAY, []interface{}{}, map[string]interface{}{})
148 // Tuesday is a constant representing the day of the week Tuesday
149 Tuesday = constructRootTerm("Tuesday", p.Term_TUESDAY, []interface{}{}, map[string]interface{}{})
150 // Wednesday is a constant representing the day of the week Wednesday
151 Wednesday = constructRootTerm("Wednesday", p.Term_WEDNESDAY, []interface{}{}, map[string]interface{}{})
152 // Thursday is a constant representing the day of the week Thursday
153 Thursday = constructRootTerm("Thursday", p.Term_THURSDAY, []interface{}{}, map[string]interface{}{})
154 // Friday is a constant representing the day of the week Friday
155 Friday = constructRootTerm("Friday", p.Term_FRIDAY, []interface{}{}, map[string]interface{}{})
156 // Saturday is a constant representing the day of the week Saturday
157 Saturday = constructRootTerm("Saturday", p.Term_SATURDAY, []interface{}{}, map[string]interface{}{})
158 // Sunday is a constant representing the day of the week Sunday
159 Sunday = constructRootTerm("Sunday", p.Term_SUNDAY, []interface{}{}, map[string]interface{}{})
160
161 // Months
162
163 // January is a constant representing the month January
164 January = constructRootTerm("January", p.Term_JANUARY, []interface{}{}, map[string]interface{}{})
165 // February is a constant representing the month February
166 February = constructRootTerm("February", p.Term_FEBRUARY, []interface{}{}, map[string]interface{}{})
167 // March is a constant representing the month March
168 March = constructRootTerm("March", p.Term_MARCH, []interface{}{}, map[string]interface{}{})
169 // April is a constant representing the month April
170 April = constructRootTerm("April", p.Term_APRIL, []interface{}{}, map[string]interface{}{})
171 // May is a constant representing the month May
172 May = constructRootTerm("May", p.Term_MAY, []interface{}{}, map[string]interface{}{})
173 // June is a constant representing the month June
174 June = constructRootTerm("June", p.Term_JUNE, []interface{}{}, map[string]interface{}{})
175 // July is a constant representing the month July
176 July = constructRootTerm("July", p.Term_JULY, []interface{}{}, map[string]interface{}{})
177 // August is a constant representing the month August
178 August = constructRootTerm("August", p.Term_AUGUST, []interface{}{}, map[string]interface{}{})
179 // September is a constant representing the month September
180 September = constructRootTerm("September", p.Term_SEPTEMBER, []interface{}{}, map[string]interface{}{})
181 // October is a constant representing the month October
182 October = constructRootTerm("October", p.Term_OCTOBER, []interface{}{}, map[string]interface{}{})
183 // November is a constant representing the month November
184 November = constructRootTerm("November", p.Term_NOVEMBER, []interface{}{}, map[string]interface{}{})
185 // December is a constant representing the month December
186 December = constructRootTerm("December", p.Term_DECEMBER, []interface{}{}, map[string]interface{}{})
187 )