dwh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +36 -0
  3. data/CHANGELOG.md +5 -0
  4. data/LICENSE +21 -0
  5. data/README.md +130 -0
  6. data/Rakefile +42 -0
  7. data/docs/DWH/Adapters/Adapter.html +3053 -0
  8. data/docs/DWH/Adapters/Athena.html +1704 -0
  9. data/docs/DWH/Adapters/Boolean.html +121 -0
  10. data/docs/DWH/Adapters/Druid.html +1626 -0
  11. data/docs/DWH/Adapters/DuckDb.html +2012 -0
  12. data/docs/DWH/Adapters/MySql.html +1704 -0
  13. data/docs/DWH/Adapters/OpenAuthorizable/ClassMethods.html +265 -0
  14. data/docs/DWH/Adapters/OpenAuthorizable.html +1102 -0
  15. data/docs/DWH/Adapters/Postgres.html +2000 -0
  16. data/docs/DWH/Adapters/Snowflake.html +1662 -0
  17. data/docs/DWH/Adapters/SqlServer.html +2084 -0
  18. data/docs/DWH/Adapters/Trino.html +1835 -0
  19. data/docs/DWH/Adapters.html +129 -0
  20. data/docs/DWH/AuthenticationError.html +142 -0
  21. data/docs/DWH/Behaviors.html +767 -0
  22. data/docs/DWH/Capabilities.html +748 -0
  23. data/docs/DWH/Column.html +1115 -0
  24. data/docs/DWH/ConfigError.html +143 -0
  25. data/docs/DWH/ConnectionError.html +143 -0
  26. data/docs/DWH/DWHError.html +138 -0
  27. data/docs/DWH/ExecutionError.html +143 -0
  28. data/docs/DWH/Factory.html +1133 -0
  29. data/docs/DWH/Functions/Arrays.html +505 -0
  30. data/docs/DWH/Functions/Dates.html +1644 -0
  31. data/docs/DWH/Functions/ExtractDatePart.html +804 -0
  32. data/docs/DWH/Functions/Nulls.html +377 -0
  33. data/docs/DWH/Functions.html +846 -0
  34. data/docs/DWH/Logger.html +258 -0
  35. data/docs/DWH/OAuthError.html +138 -0
  36. data/docs/DWH/Settings.html +658 -0
  37. data/docs/DWH/StreamingStats.html +804 -0
  38. data/docs/DWH/Table.html +1260 -0
  39. data/docs/DWH/TableStats.html +583 -0
  40. data/docs/DWH/TokenExpiredError.html +142 -0
  41. data/docs/DWH/UnsupportedCapability.html +135 -0
  42. data/docs/DWH.html +220 -0
  43. data/docs/_index.html +471 -0
  44. data/docs/class_list.html +54 -0
  45. data/docs/css/common.css +1 -0
  46. data/docs/css/full_list.css +58 -0
  47. data/docs/css/style.css +503 -0
  48. data/docs/file.README.html +210 -0
  49. data/docs/file.adapters.html +514 -0
  50. data/docs/file.creating-adapters.html +497 -0
  51. data/docs/file.getting-started.html +288 -0
  52. data/docs/file.usage.html +446 -0
  53. data/docs/file_list.html +79 -0
  54. data/docs/frames.html +22 -0
  55. data/docs/guides/adapters.md +445 -0
  56. data/docs/guides/creating-adapters.md +430 -0
  57. data/docs/guides/getting-started.md +225 -0
  58. data/docs/guides/usage.md +378 -0
  59. data/docs/index.html +210 -0
  60. data/docs/js/app.js +344 -0
  61. data/docs/js/full_list.js +242 -0
  62. data/docs/js/jquery.js +4 -0
  63. data/docs/method_list.html +2038 -0
  64. data/docs/top-level-namespace.html +110 -0
  65. data/lib/dwh/adapters/athena.rb +359 -0
  66. data/lib/dwh/adapters/druid.rb +267 -0
  67. data/lib/dwh/adapters/duck_db.rb +235 -0
  68. data/lib/dwh/adapters/my_sql.rb +235 -0
  69. data/lib/dwh/adapters/open_authorizable.rb +215 -0
  70. data/lib/dwh/adapters/postgres.rb +250 -0
  71. data/lib/dwh/adapters/snowflake.rb +489 -0
  72. data/lib/dwh/adapters/sql_server.rb +257 -0
  73. data/lib/dwh/adapters/trino.rb +213 -0
  74. data/lib/dwh/adapters.rb +363 -0
  75. data/lib/dwh/behaviors.rb +67 -0
  76. data/lib/dwh/capabilities.rb +39 -0
  77. data/lib/dwh/column.rb +79 -0
  78. data/lib/dwh/errors.rb +29 -0
  79. data/lib/dwh/factory.rb +125 -0
  80. data/lib/dwh/functions/arrays.rb +42 -0
  81. data/lib/dwh/functions/dates.rb +162 -0
  82. data/lib/dwh/functions/extract_date_part.rb +70 -0
  83. data/lib/dwh/functions/nulls.rb +31 -0
  84. data/lib/dwh/functions.rb +86 -0
  85. data/lib/dwh/logger.rb +50 -0
  86. data/lib/dwh/settings/athena.yml +77 -0
  87. data/lib/dwh/settings/base.yml +81 -0
  88. data/lib/dwh/settings/databricks.yml +51 -0
  89. data/lib/dwh/settings/druid.yml +59 -0
  90. data/lib/dwh/settings/duckdb.yml +44 -0
  91. data/lib/dwh/settings/mysql.yml +67 -0
  92. data/lib/dwh/settings/postgres.yml +30 -0
  93. data/lib/dwh/settings/redshift.yml +52 -0
  94. data/lib/dwh/settings/snowflake.yml +45 -0
  95. data/lib/dwh/settings/sqlserver.yml +80 -0
  96. data/lib/dwh/settings/trino.yml +77 -0
  97. data/lib/dwh/settings.rb +79 -0
  98. data/lib/dwh/streaming_stats.rb +69 -0
  99. data/lib/dwh/table.rb +105 -0
  100. data/lib/dwh/table_stats.rb +51 -0
  101. data/lib/dwh/version.rb +5 -0
  102. data/lib/dwh.rb +54 -0
  103. data/sig/dwh.rbs +4 -0
  104. metadata +231 -0
@@ -0,0 +1,1644 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: DWH::Functions::Dates
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "DWH::Functions::Dates";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (D)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../DWH.html" title="DWH (module)">DWH</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Functions.html" title="DWH::Functions (module)">Functions</a></span></span>
41
+ &raquo;
42
+ <span class="title">Dates</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: DWH::Functions::Dates
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <dl>
78
+ <dt>Included in:</dt>
79
+ <dd><span class='object_link'><a href="../Functions.html" title="DWH::Functions (module)">DWH::Functions</a></span></dd>
80
+ </dl>
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/dwh/functions/dates.rb</dd>
87
+ </dl>
88
+
89
+ </div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+ <p>Standard date functions except for those dealing with extracting
94
+ a date part.</p>
95
+
96
+
97
+ </div>
98
+ </div>
99
+ <div class="tags">
100
+
101
+
102
+ </div>
103
+
104
+ <h2>
105
+ Constant Summary
106
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
107
+ </h2>
108
+
109
+ <dl class="constants">
110
+
111
+ <dt id="TIMESTAMPABLE_UNITS-constant" class="">TIMESTAMPABLE_UNITS =
112
+
113
+ </dt>
114
+ <dd><pre class="code"><span class='qwords_beg'>%w[</span><span class='tstring_content'>millisecond</span><span class='words_sep'> </span><span class='tstring_content'>second</span><span class='words_sep'> </span><span class='tstring_content'>minute</span><span class='words_sep'> </span><span class='tstring_content'>hour</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
115
+
116
+ <dt id="DATE_CLASSES-constant" class="">DATE_CLASSES =
117
+
118
+ </dt>
119
+ <dd><pre class="code"><span class='lbracket'>[</span><span class='const'>Date</span><span class='comma'>,</span> <span class='const'>DateTime</span><span class='comma'>,</span> <span class='const'>Time</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
120
+
121
+ </dl>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <h2>
132
+ Instance Method Summary
133
+ <small><a href="#" class="summary_toggle">collapse</a></small>
134
+ </h2>
135
+
136
+ <ul class="summary">
137
+
138
+ <li class="public ">
139
+ <span class="summary_signature">
140
+
141
+ <a href="#adjust_week_start_day-instance_method" title="#adjust_week_start_day (instance method)">#<strong>adjust_week_start_day</strong>(exp) &#x21d2; Object </a>
142
+
143
+
144
+
145
+ </span>
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+ <span class="summary_desc"><div class='inline'><p>Apply translation to desired week start day.</p>
156
+ </div></span>
157
+
158
+ </li>
159
+
160
+
161
+ <li class="public ">
162
+ <span class="summary_signature">
163
+
164
+ <a href="#adjust_week_start_day%3F-instance_method" title="#adjust_week_start_day? (instance method)">#<strong>adjust_week_start_day?</strong> &#x21d2; Boolean </a>
165
+
166
+
167
+
168
+ </span>
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+ <span class="summary_desc"><div class='inline'><p>Whether we need to adjust the week start day.</p>
179
+ </div></span>
180
+
181
+ </li>
182
+
183
+
184
+ <li class="public ">
185
+ <span class="summary_signature">
186
+
187
+ <a href="#current_date-instance_method" title="#current_date (instance method)">#<strong>current_date</strong> &#x21d2; Object </a>
188
+
189
+
190
+
191
+ </span>
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+ <span class="summary_desc"><div class='inline'><p>The native function to return current date.</p>
202
+ </div></span>
203
+
204
+ </li>
205
+
206
+
207
+ <li class="public ">
208
+ <span class="summary_signature">
209
+
210
+ <a href="#current_time-instance_method" title="#current_time (instance method)">#<strong>current_time</strong> &#x21d2; Object </a>
211
+
212
+
213
+
214
+ </span>
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+ <span class="summary_desc"><div class='inline'><p>The native function to return current time.</p>
225
+ </div></span>
226
+
227
+ </li>
228
+
229
+
230
+ <li class="public ">
231
+ <span class="summary_signature">
232
+
233
+ <a href="#current_timestamp-instance_method" title="#current_timestamp (instance method)">#<strong>current_timestamp</strong> &#x21d2; Object </a>
234
+
235
+
236
+
237
+ </span>
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <span class="summary_desc"><div class='inline'><p>The native function to return current timestamp.</p>
248
+ </div></span>
249
+
250
+ </li>
251
+
252
+
253
+ <li class="public ">
254
+ <span class="summary_signature">
255
+
256
+ <a href="#date_add-instance_method" title="#date_add (instance method)">#<strong>date_add</strong>(unit, val, exp) &#x21d2; Object </a>
257
+
258
+
259
+
260
+ </span>
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+ <span class="summary_desc"><div class='inline'><p>Add some interval of time to a given date expression.</p>
271
+ </div></span>
272
+
273
+ </li>
274
+
275
+
276
+ <li class="public ">
277
+ <span class="summary_signature">
278
+
279
+ <a href="#date_data_type-instance_method" title="#date_data_type (instance method)">#<strong>date_data_type</strong> &#x21d2; Object </a>
280
+
281
+
282
+
283
+ </span>
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+ <span class="summary_desc"><div class='inline'><p>The native date storage type of the db.</p>
294
+ </div></span>
295
+
296
+ </li>
297
+
298
+
299
+ <li class="public ">
300
+ <span class="summary_signature">
301
+
302
+ <a href="#date_diff-instance_method" title="#date_diff (instance method)">#<strong>date_diff</strong>(unit, start_exp, end_exp) &#x21d2; Object </a>
303
+
304
+
305
+
306
+ </span>
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+ <span class="summary_desc"><div class='inline'><p>Differnect between two dates in terms of the given unit.</p>
317
+ </div></span>
318
+
319
+ </li>
320
+
321
+
322
+ <li class="public ">
323
+ <span class="summary_signature">
324
+
325
+ <a href="#date_format-instance_method" title="#date_format (instance method)">#<strong>date_format</strong> &#x21d2; Object </a>
326
+
327
+
328
+
329
+ </span>
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+ <span class="summary_desc"><div class='inline'><p>Ruby format string that is compatible for the target database.</p>
340
+ </div></span>
341
+
342
+ </li>
343
+
344
+
345
+ <li class="public ">
346
+ <span class="summary_signature">
347
+
348
+ <a href="#date_format_sql-instance_method" title="#date_format_sql (instance method)">#<strong>date_format_sql</strong>(exp, format) &#x21d2; Object </a>
349
+
350
+
351
+
352
+ </span>
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+ <span class="summary_desc"><div class='inline'><p>Applies the given format to the target date expression.</p>
363
+ </div></span>
364
+
365
+ </li>
366
+
367
+
368
+ <li class="public ">
369
+ <span class="summary_signature">
370
+
371
+ <a href="#date_int%3F-instance_method" title="#date_int? (instance method)">#<strong>date_int?</strong> &#x21d2; Boolean </a>
372
+
373
+
374
+
375
+ </span>
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+ <span class="summary_desc"><div class='inline'><p>Whether the db uses an int format store dates natively.</p>
386
+ </div></span>
387
+
388
+ </li>
389
+
390
+
391
+ <li class="public ">
392
+ <span class="summary_signature">
393
+
394
+ <a href="#date_literal-instance_method" title="#date_literal (instance method)">#<strong>date_literal</strong>(val) &#x21d2; Object </a>
395
+
396
+
397
+
398
+ </span>
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+ <span class="summary_desc"><div class='inline'><p>Generates a valid date literal string.</p>
409
+ </div></span>
410
+
411
+ </li>
412
+
413
+
414
+ <li class="public ">
415
+ <span class="summary_signature">
416
+
417
+ <a href="#date_time_format-instance_method" title="#date_time_format (instance method)">#<strong>date_time_format</strong> &#x21d2; Object </a>
418
+
419
+
420
+
421
+ </span>
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+ <span class="summary_desc"><div class='inline'><p>Ruby format string that is compatible timestamp format for the target db.</p>
432
+ </div></span>
433
+
434
+ </li>
435
+
436
+
437
+ <li class="public ">
438
+ <span class="summary_signature">
439
+
440
+ <a href="#date_time_literal-instance_method" title="#date_time_literal (instance method)">#<strong>date_time_literal</strong>(val) &#x21d2; Object </a>
441
+
442
+
443
+
444
+ </span>
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+ <span class="summary_desc"><div class='inline'>
455
+ </div></span>
456
+
457
+ </li>
458
+
459
+
460
+ <li class="public ">
461
+ <span class="summary_signature">
462
+
463
+ <a href="#date_time_tz_format-instance_method" title="#date_time_tz_format (instance method)">#<strong>date_time_tz_format</strong> &#x21d2; Object </a>
464
+
465
+
466
+
467
+ </span>
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+ <span class="summary_desc"><div class='inline'><p>Ruby format string that is compatible timestamp with timezone format for the target db.</p>
478
+ </div></span>
479
+
480
+ </li>
481
+
482
+
483
+ <li class="public ">
484
+ <span class="summary_signature">
485
+
486
+ <a href="#default_week_start_day-instance_method" title="#default_week_start_day (instance method)">#<strong>default_week_start_day</strong> &#x21d2; Object </a>
487
+
488
+
489
+
490
+ </span>
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+ <span class="summary_desc"><div class='inline'><p>The current default week start day.</p>
501
+ </div></span>
502
+
503
+ </li>
504
+
505
+
506
+ <li class="public ">
507
+ <span class="summary_signature">
508
+
509
+ <a href="#truncate_date-instance_method" title="#truncate_date (instance method)">#<strong>truncate_date</strong>(unit, exp) &#x21d2; Object </a>
510
+
511
+
512
+
513
+ </span>
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+ <span class="summary_desc"><div class='inline'><p>Given a date expression, truncate it to a given level.</p>
524
+ </div></span>
525
+
526
+ </li>
527
+
528
+
529
+ <li class="public ">
530
+ <span class="summary_signature">
531
+
532
+ <a href="#week_start_day-instance_method" title="#week_start_day (instance method)">#<strong>week_start_day</strong> &#x21d2; Object </a>
533
+
534
+
535
+
536
+ </span>
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+ <span class="summary_desc"><div class='inline'><p>The desired week start day.</p>
547
+ </div></span>
548
+
549
+ </li>
550
+
551
+
552
+ <li class="public ">
553
+ <span class="summary_signature">
554
+
555
+ <a href="#week_starts_on_sunday%3F-instance_method" title="#week_starts_on_sunday? (instance method)">#<strong>week_starts_on_sunday?</strong> &#x21d2; Boolean </a>
556
+
557
+
558
+
559
+ </span>
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+ <span class="summary_desc"><div class='inline'><p>Does the week start on sunday?.</p>
570
+ </div></span>
571
+
572
+ </li>
573
+
574
+
575
+ </ul>
576
+
577
+
578
+
579
+
580
+ <div id="instance_method_details" class="method_details_list">
581
+ <h2>Instance Method Details</h2>
582
+
583
+
584
+ <div class="method_details first">
585
+ <h3 class="signature first" id="adjust_week_start_day-instance_method">
586
+
587
+ #<strong>adjust_week_start_day</strong>(exp) &#x21d2; <tt>Object</tt>
588
+
589
+
590
+
591
+
592
+
593
+ </h3><div class="docstring">
594
+ <div class="discussion">
595
+ <p>Apply translation to desired week start day</p>
596
+
597
+
598
+ </div>
599
+ </div>
600
+ <div class="tags">
601
+
602
+
603
+ </div><table class="source_code">
604
+ <tr>
605
+ <td>
606
+ <pre class="lines">
607
+
608
+
609
+ 151
610
+ 152
611
+ 153
612
+ 154</pre>
613
+ </td>
614
+ <td>
615
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 151</span>
616
+
617
+ <span class='kw'>def</span> <span class='id identifier rubyid_adjust_week_start_day'>adjust_week_start_day</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
618
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:week_start_day</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>_week_start_day</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
619
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
620
+ <span class='kw'>end</span></pre>
621
+ </td>
622
+ </tr>
623
+ </table>
624
+ </div>
625
+
626
+ <div class="method_details ">
627
+ <h3 class="signature " id="adjust_week_start_day?-instance_method">
628
+
629
+ #<strong>adjust_week_start_day?</strong> &#x21d2; <tt>Boolean</tt>
630
+
631
+
632
+
633
+
634
+
635
+ </h3><div class="docstring">
636
+ <div class="discussion">
637
+ <p>Whether we need to adjust the week start day. If its different
638
+ from the default, we need to adjust</p>
639
+
640
+
641
+ </div>
642
+ </div>
643
+ <div class="tags">
644
+
645
+ <p class="tag_title">Returns:</p>
646
+ <ul class="return">
647
+
648
+ <li>
649
+
650
+
651
+ <span class='type'>(<tt>Boolean</tt>)</span>
652
+
653
+
654
+
655
+ </li>
656
+
657
+ </ul>
658
+
659
+ </div><table class="source_code">
660
+ <tr>
661
+ <td>
662
+ <pre class="lines">
663
+
664
+
665
+ 146
666
+ 147
667
+ 148</pre>
668
+ </td>
669
+ <td>
670
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 146</span>
671
+
672
+ <span class='kw'>def</span> <span class='id identifier rubyid_adjust_week_start_day?'>adjust_week_start_day?</span>
673
+ <span class='id identifier rubyid_week_start_day'>week_start_day</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='op'>!=</span> <span class='id identifier rubyid_default_week_start_day'>default_week_start_day</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
674
+ <span class='kw'>end</span></pre>
675
+ </td>
676
+ </tr>
677
+ </table>
678
+ </div>
679
+
680
+ <div class="method_details ">
681
+ <h3 class="signature " id="current_date-instance_method">
682
+
683
+ #<strong>current_date</strong> &#x21d2; <tt>Object</tt>
684
+
685
+
686
+
687
+
688
+
689
+ </h3><div class="docstring">
690
+ <div class="discussion">
691
+ <p>The native function to return current date</p>
692
+
693
+
694
+ </div>
695
+ </div>
696
+ <div class="tags">
697
+
698
+
699
+ </div><table class="source_code">
700
+ <tr>
701
+ <td>
702
+ <pre class="lines">
703
+
704
+
705
+ 34
706
+ 35
707
+ 36</pre>
708
+ </td>
709
+ <td>
710
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 34</span>
711
+
712
+ <span class='kw'>def</span> <span class='id identifier rubyid_current_date'>current_date</span>
713
+ <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:current_date</span><span class='rbracket'>]</span>
714
+ <span class='kw'>end</span></pre>
715
+ </td>
716
+ </tr>
717
+ </table>
718
+ </div>
719
+
720
+ <div class="method_details ">
721
+ <h3 class="signature " id="current_time-instance_method">
722
+
723
+ #<strong>current_time</strong> &#x21d2; <tt>Object</tt>
724
+
725
+
726
+
727
+
728
+
729
+ </h3><div class="docstring">
730
+ <div class="discussion">
731
+ <p>The native function to return current time</p>
732
+
733
+
734
+ </div>
735
+ </div>
736
+ <div class="tags">
737
+
738
+
739
+ </div><table class="source_code">
740
+ <tr>
741
+ <td>
742
+ <pre class="lines">
743
+
744
+
745
+ 39
746
+ 40
747
+ 41</pre>
748
+ </td>
749
+ <td>
750
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 39</span>
751
+
752
+ <span class='kw'>def</span> <span class='id identifier rubyid_current_time'>current_time</span>
753
+ <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:current_time</span><span class='rbracket'>]</span>
754
+ <span class='kw'>end</span></pre>
755
+ </td>
756
+ </tr>
757
+ </table>
758
+ </div>
759
+
760
+ <div class="method_details ">
761
+ <h3 class="signature " id="current_timestamp-instance_method">
762
+
763
+ #<strong>current_timestamp</strong> &#x21d2; <tt>Object</tt>
764
+
765
+
766
+
767
+
768
+
769
+ </h3><div class="docstring">
770
+ <div class="discussion">
771
+ <p>The native function to return current timestamp</p>
772
+
773
+
774
+ </div>
775
+ </div>
776
+ <div class="tags">
777
+
778
+
779
+ </div><table class="source_code">
780
+ <tr>
781
+ <td>
782
+ <pre class="lines">
783
+
784
+
785
+ 44
786
+ 45
787
+ 46</pre>
788
+ </td>
789
+ <td>
790
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 44</span>
791
+
792
+ <span class='kw'>def</span> <span class='id identifier rubyid_current_timestamp'>current_timestamp</span>
793
+ <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:current_timestamp</span><span class='rbracket'>]</span>
794
+ <span class='kw'>end</span></pre>
795
+ </td>
796
+ </tr>
797
+ </table>
798
+ </div>
799
+
800
+ <div class="method_details ">
801
+ <h3 class="signature " id="date_add-instance_method">
802
+
803
+ #<strong>date_add</strong>(unit, val, exp) &#x21d2; <tt>Object</tt>
804
+
805
+
806
+
807
+
808
+
809
+ </h3><div class="docstring">
810
+ <div class="discussion">
811
+ <p>Add some interval of time to a given date expression.</p>
812
+
813
+
814
+ </div>
815
+ </div>
816
+ <div class="tags">
817
+ <p class="tag_title">Parameters:</p>
818
+ <ul class="param">
819
+
820
+ <li>
821
+
822
+ <span class='name'>unit</span>
823
+
824
+
825
+ <span class='type'>(<tt>String</tt>)</span>
826
+
827
+
828
+
829
+ &mdash;
830
+ <div class='inline'><p>the units we are adding i.e day, month, week etc</p>
831
+ </div>
832
+
833
+ </li>
834
+
835
+ <li>
836
+
837
+ <span class='name'>val</span>
838
+
839
+
840
+ <span class='type'>(<tt>Integer</tt>)</span>
841
+
842
+
843
+
844
+ &mdash;
845
+ <div class='inline'><p>the number of said units</p>
846
+ </div>
847
+
848
+ </li>
849
+
850
+ <li>
851
+
852
+ <span class='name'>exp</span>
853
+
854
+
855
+ <span class='type'>(<tt>String</tt>)</span>
856
+
857
+
858
+
859
+ &mdash;
860
+ <div class='inline'><p>the target expression being operated on</p>
861
+ </div>
862
+
863
+ </li>
864
+
865
+ </ul>
866
+
867
+
868
+ </div><table class="source_code">
869
+ <tr>
870
+ <td>
871
+ <pre class="lines">
872
+
873
+
874
+ 91
875
+ 92
876
+ 93
877
+ 94
878
+ 95
879
+ 96</pre>
880
+ </td>
881
+ <td>
882
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 91</span>
883
+
884
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_add'>date_add</span><span class='lparen'>(</span><span class='id identifier rubyid_unit'>unit</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
885
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:date_add</span><span class='rparen'>)</span>
886
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@unit</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_unit'>unit</span><span class='rparen'>)</span>
887
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@val</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
888
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
889
+ <span class='kw'>end</span></pre>
890
+ </td>
891
+ </tr>
892
+ </table>
893
+ </div>
894
+
895
+ <div class="method_details ">
896
+ <h3 class="signature " id="date_data_type-instance_method">
897
+
898
+ #<strong>date_data_type</strong> &#x21d2; <tt>Object</tt>
899
+
900
+
901
+
902
+
903
+
904
+ </h3><div class="docstring">
905
+ <div class="discussion">
906
+ <p>The native date storage type of the db.</p>
907
+
908
+
909
+ </div>
910
+ </div>
911
+ <div class="tags">
912
+
913
+
914
+ </div><table class="source_code">
915
+ <tr>
916
+ <td>
917
+ <pre class="lines">
918
+
919
+
920
+ 24
921
+ 25
922
+ 26</pre>
923
+ </td>
924
+ <td>
925
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 24</span>
926
+
927
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_data_type'>date_data_type</span>
928
+ <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:data_type</span><span class='rbracket'>]</span>
929
+ <span class='kw'>end</span></pre>
930
+ </td>
931
+ </tr>
932
+ </table>
933
+ </div>
934
+
935
+ <div class="method_details ">
936
+ <h3 class="signature " id="date_diff-instance_method">
937
+
938
+ #<strong>date_diff</strong>(unit, start_exp, end_exp) &#x21d2; <tt>Object</tt>
939
+
940
+
941
+
942
+
943
+
944
+ </h3><div class="docstring">
945
+ <div class="discussion">
946
+ <p>Differnect between two dates in terms of the given unit.</p>
947
+
948
+
949
+ </div>
950
+ </div>
951
+ <div class="tags">
952
+ <p class="tag_title">Parameters:</p>
953
+ <ul class="param">
954
+
955
+ <li>
956
+
957
+ <span class='name'>unit</span>
958
+
959
+
960
+ <span class='type'>(<tt>String</tt>)</span>
961
+
962
+
963
+
964
+ &mdash;
965
+ <div class='inline'><p>i.e day, month, hour etc</p>
966
+ </div>
967
+
968
+ </li>
969
+
970
+ <li>
971
+
972
+ <span class='name'>start_exp</span>
973
+
974
+
975
+ <span class='type'>(<tt>String</tt>)</span>
976
+
977
+
978
+
979
+ &mdash;
980
+ <div class='inline'><p>starting date expression</p>
981
+ </div>
982
+
983
+ </li>
984
+
985
+ <li>
986
+
987
+ <span class='name'>end_exp</span>
988
+
989
+
990
+ <span class='type'>(<tt>String</tt>)</span>
991
+
992
+
993
+
994
+ &mdash;
995
+ <div class='inline'><p>ending date expression</p>
996
+ </div>
997
+
998
+ </li>
999
+
1000
+ </ul>
1001
+
1002
+
1003
+ </div><table class="source_code">
1004
+ <tr>
1005
+ <td>
1006
+ <pre class="lines">
1007
+
1008
+
1009
+ 102
1010
+ 103
1011
+ 104
1012
+ 105
1013
+ 106
1014
+ 107</pre>
1015
+ </td>
1016
+ <td>
1017
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 102</span>
1018
+
1019
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_diff'>date_diff</span><span class='lparen'>(</span><span class='id identifier rubyid_unit'>unit</span><span class='comma'>,</span> <span class='id identifier rubyid_start_exp'>start_exp</span><span class='comma'>,</span> <span class='id identifier rubyid_end_exp'>end_exp</span><span class='rparen'>)</span>
1020
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:date_diff</span><span class='rparen'>)</span>
1021
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@unit</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_unit'>unit</span><span class='rparen'>)</span>
1022
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@start_exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_start_exp'>start_exp</span><span class='rparen'>)</span>
1023
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@end_exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_end_exp'>end_exp</span><span class='rparen'>)</span>
1024
+ <span class='kw'>end</span></pre>
1025
+ </td>
1026
+ </tr>
1027
+ </table>
1028
+ </div>
1029
+
1030
+ <div class="method_details ">
1031
+ <h3 class="signature " id="date_format-instance_method">
1032
+
1033
+ #<strong>date_format</strong> &#x21d2; <tt>Object</tt>
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+ </h3><div class="docstring">
1040
+ <div class="discussion">
1041
+ <p>Ruby format string that is compatible for the target database.</p>
1042
+
1043
+
1044
+ </div>
1045
+ </div>
1046
+ <div class="tags">
1047
+
1048
+
1049
+ </div><table class="source_code">
1050
+ <tr>
1051
+ <td>
1052
+ <pre class="lines">
1053
+
1054
+
1055
+ 7
1056
+ 8
1057
+ 9</pre>
1058
+ </td>
1059
+ <td>
1060
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 7</span>
1061
+
1062
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_format'>date_format</span>
1063
+ <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:date_format</span><span class='rbracket'>]</span>
1064
+ <span class='kw'>end</span></pre>
1065
+ </td>
1066
+ </tr>
1067
+ </table>
1068
+ </div>
1069
+
1070
+ <div class="method_details ">
1071
+ <h3 class="signature " id="date_format_sql-instance_method">
1072
+
1073
+ #<strong>date_format_sql</strong>(exp, format) &#x21d2; <tt>Object</tt>
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+ </h3><div class="docstring">
1080
+ <div class="discussion">
1081
+ <p>Applies the given format to the target date expression</p>
1082
+
1083
+
1084
+ </div>
1085
+ </div>
1086
+ <div class="tags">
1087
+
1088
+
1089
+ </div><table class="source_code">
1090
+ <tr>
1091
+ <td>
1092
+ <pre class="lines">
1093
+
1094
+
1095
+ 110
1096
+ 111
1097
+ 112
1098
+ 113
1099
+ 114</pre>
1100
+ </td>
1101
+ <td>
1102
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 110</span>
1103
+
1104
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_format_sql'>date_format_sql</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
1105
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:date_format_sql</span><span class='rparen'>)</span>
1106
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
1107
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@format</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
1108
+ <span class='kw'>end</span></pre>
1109
+ </td>
1110
+ </tr>
1111
+ </table>
1112
+ </div>
1113
+
1114
+ <div class="method_details ">
1115
+ <h3 class="signature " id="date_int?-instance_method">
1116
+
1117
+ #<strong>date_int?</strong> &#x21d2; <tt>Boolean</tt>
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+ </h3><div class="docstring">
1124
+ <div class="discussion">
1125
+ <p>Whether the db uses an int format store dates natively</p>
1126
+
1127
+
1128
+ </div>
1129
+ </div>
1130
+ <div class="tags">
1131
+
1132
+ <p class="tag_title">Returns:</p>
1133
+ <ul class="return">
1134
+
1135
+ <li>
1136
+
1137
+
1138
+ <span class='type'>(<tt>Boolean</tt>)</span>
1139
+
1140
+
1141
+
1142
+ </li>
1143
+
1144
+ </ul>
1145
+
1146
+ </div><table class="source_code">
1147
+ <tr>
1148
+ <td>
1149
+ <pre class="lines">
1150
+
1151
+
1152
+ 29
1153
+ 30
1154
+ 31</pre>
1155
+ </td>
1156
+ <td>
1157
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 29</span>
1158
+
1159
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_int?'>date_int?</span>
1160
+ <span class='id identifier rubyid_date_data_type'>date_data_type</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>int</span><span class='regexp_end'>/i</span></span>
1161
+ <span class='kw'>end</span></pre>
1162
+ </td>
1163
+ </tr>
1164
+ </table>
1165
+ </div>
1166
+
1167
+ <div class="method_details ">
1168
+ <h3 class="signature " id="date_literal-instance_method">
1169
+
1170
+ #<strong>date_literal</strong>(val) &#x21d2; <tt>Object</tt>
1171
+
1172
+
1173
+
1174
+
1175
+
1176
+ </h3><div class="docstring">
1177
+ <div class="discussion">
1178
+ <p>Generates a valid date literal string. Most db’s
1179
+ this is just single quoted value while others require
1180
+ a date declaration.</p>
1181
+
1182
+
1183
+ </div>
1184
+ </div>
1185
+ <div class="tags">
1186
+ <p class="tag_title">Parameters:</p>
1187
+ <ul class="param">
1188
+
1189
+ <li>
1190
+
1191
+ <span class='name'>val</span>
1192
+
1193
+
1194
+ <span class='type'>(<tt>String</tt>, <tt>Date</tt>, <tt>DateTime</tt>, <tt>Time</tt>)</span>
1195
+
1196
+
1197
+
1198
+ </li>
1199
+
1200
+ </ul>
1201
+
1202
+
1203
+ </div><table class="source_code">
1204
+ <tr>
1205
+ <td>
1206
+ <pre class="lines">
1207
+
1208
+
1209
+ 122
1210
+ 123
1211
+ 124
1212
+ 125</pre>
1213
+ </td>
1214
+ <td>
1215
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 122</span>
1216
+
1217
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_literal'>date_literal</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
1218
+ <span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#DATE_CLASSES-constant" title="DWH::Functions::Dates::DATE_CLASSES (constant)">DATE_CLASSES</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_val'>val</span><span class='period'>.</span><span class='id identifier rubyid_strftime'>strftime</span><span class='lparen'>(</span><span class='id identifier rubyid_date_format'>date_format</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_val'>val</span>
1219
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:date_literal</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@val</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
1220
+ <span class='kw'>end</span></pre>
1221
+ </td>
1222
+ </tr>
1223
+ </table>
1224
+ </div>
1225
+
1226
+ <div class="method_details ">
1227
+ <h3 class="signature " id="date_time_format-instance_method">
1228
+
1229
+ #<strong>date_time_format</strong> &#x21d2; <tt>Object</tt>
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+ </h3><div class="docstring">
1236
+ <div class="discussion">
1237
+ <p>Ruby format string that is compatible timestamp format
1238
+ for the target db.</p>
1239
+
1240
+
1241
+ </div>
1242
+ </div>
1243
+ <div class="tags">
1244
+
1245
+
1246
+ </div><table class="source_code">
1247
+ <tr>
1248
+ <td>
1249
+ <pre class="lines">
1250
+
1251
+
1252
+ 13
1253
+ 14
1254
+ 15</pre>
1255
+ </td>
1256
+ <td>
1257
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 13</span>
1258
+
1259
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_time_format'>date_time_format</span>
1260
+ <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:date_time_format</span><span class='rbracket'>]</span>
1261
+ <span class='kw'>end</span></pre>
1262
+ </td>
1263
+ </tr>
1264
+ </table>
1265
+ </div>
1266
+
1267
+ <div class="method_details ">
1268
+ <h3 class="signature " id="date_time_literal-instance_method">
1269
+
1270
+ #<strong>date_time_literal</strong>(val) &#x21d2; <tt>Object</tt>
1271
+
1272
+
1273
+
1274
+
1275
+
1276
+ </h3><div class="docstring">
1277
+ <div class="discussion">
1278
+
1279
+
1280
+
1281
+ </div>
1282
+ </div>
1283
+ <div class="tags">
1284
+ <p class="tag_title">Parameters:</p>
1285
+ <ul class="param">
1286
+
1287
+ <li>
1288
+
1289
+ <span class='name'>val</span>
1290
+
1291
+
1292
+ <span class='type'>(<tt>String</tt>, <tt>Date</tt>, <tt>DateTime</tt>, <tt>Time</tt>)</span>
1293
+
1294
+
1295
+
1296
+ </li>
1297
+
1298
+ </ul>
1299
+
1300
+
1301
+ </div><table class="source_code">
1302
+ <tr>
1303
+ <td>
1304
+ <pre class="lines">
1305
+
1306
+
1307
+ 128
1308
+ 129
1309
+ 130
1310
+ 131</pre>
1311
+ </td>
1312
+ <td>
1313
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 128</span>
1314
+
1315
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_time_literal'>date_time_literal</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
1316
+ <span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#DATE_CLASSES-constant" title="DWH::Functions::Dates::DATE_CLASSES (constant)">DATE_CLASSES</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_val'>val</span><span class='period'>.</span><span class='id identifier rubyid_strftime'>strftime</span><span class='lparen'>(</span><span class='id identifier rubyid_date_time_format'>date_time_format</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_val'>val</span>
1317
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:date_time_literal</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@val</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
1318
+ <span class='kw'>end</span></pre>
1319
+ </td>
1320
+ </tr>
1321
+ </table>
1322
+ </div>
1323
+
1324
+ <div class="method_details ">
1325
+ <h3 class="signature " id="date_time_tz_format-instance_method">
1326
+
1327
+ #<strong>date_time_tz_format</strong> &#x21d2; <tt>Object</tt>
1328
+
1329
+
1330
+
1331
+
1332
+
1333
+ </h3><div class="docstring">
1334
+ <div class="discussion">
1335
+ <p>Ruby format string that is compatible timestamp with timezone
1336
+ format for the target db.</p>
1337
+
1338
+
1339
+ </div>
1340
+ </div>
1341
+ <div class="tags">
1342
+
1343
+
1344
+ </div><table class="source_code">
1345
+ <tr>
1346
+ <td>
1347
+ <pre class="lines">
1348
+
1349
+
1350
+ 19
1351
+ 20
1352
+ 21</pre>
1353
+ </td>
1354
+ <td>
1355
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 19</span>
1356
+
1357
+ <span class='kw'>def</span> <span class='id identifier rubyid_date_time_tz_format'>date_time_tz_format</span>
1358
+ <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:date_time_tz_format</span><span class='rbracket'>]</span>
1359
+ <span class='kw'>end</span></pre>
1360
+ </td>
1361
+ </tr>
1362
+ </table>
1363
+ </div>
1364
+
1365
+ <div class="method_details ">
1366
+ <h3 class="signature " id="default_week_start_day-instance_method">
1367
+
1368
+ #<strong>default_week_start_day</strong> &#x21d2; <tt>Object</tt>
1369
+
1370
+
1371
+
1372
+
1373
+
1374
+ </h3><div class="docstring">
1375
+ <div class="discussion">
1376
+ <p>The current default week start day. This is how
1377
+ the db is currently setup. Should be either monday or sunday</p>
1378
+
1379
+
1380
+ </div>
1381
+ </div>
1382
+ <div class="tags">
1383
+
1384
+
1385
+ </div><table class="source_code">
1386
+ <tr>
1387
+ <td>
1388
+ <pre class="lines">
1389
+
1390
+
1391
+ 135
1392
+ 136
1393
+ 137</pre>
1394
+ </td>
1395
+ <td>
1396
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 135</span>
1397
+
1398
+ <span class='kw'>def</span> <span class='id identifier rubyid_default_week_start_day'>default_week_start_day</span>
1399
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:default_week_start_day</span><span class='rparen'>)</span>
1400
+ <span class='kw'>end</span></pre>
1401
+ </td>
1402
+ </tr>
1403
+ </table>
1404
+ </div>
1405
+
1406
+ <div class="method_details ">
1407
+ <h3 class="signature " id="truncate_date-instance_method">
1408
+
1409
+ #<strong>truncate_date</strong>(unit, exp) &#x21d2; <tt>Object</tt>
1410
+
1411
+
1412
+
1413
+
1414
+
1415
+ </h3><div class="docstring">
1416
+ <div class="discussion">
1417
+
1418
+ <div class="note notetag">
1419
+ <strong>Note:</strong>
1420
+ <div class='inline'><p>When truncating a literal date rather than an
1421
+ expression, the date_literal function should be called on
1422
+ it first. e.g. truncate_date(‘week’, date_lit(‘2025-08-06’))
1423
+ For many dbs it won’t matter, but some require date literals
1424
+ to be specified.</p>
1425
+ </div>
1426
+ </div>
1427
+
1428
+ <p>Given a date expression, truncate it to a given level.
1429
+ The SQL output of a truncation is still date or timestamp.</p>
1430
+
1431
+
1432
+ </div>
1433
+ </div>
1434
+ <div class="tags">
1435
+
1436
+ <div class="examples">
1437
+ <h4 class="tag_title">Examples:</h4>
1438
+
1439
+
1440
+ <h5 class="example_title"><div class='inline'><p>Truncate date to the week start day</p>
1441
+ </div></h5>
1442
+
1443
+ <pre class="example code"><code>truncate_date(&#39;week&#39;, &#39;my_date_col&#39;)
1444
+ Postgres ==&gt; DATE_TRUNC(&#39;week&#39;, &#39;my_date_col&#39;)
1445
+ SQL Server ==&gt; DATETRUNC(week, &#39;my_date_col&#39;)</code></pre>
1446
+
1447
+ </div>
1448
+ <p class="tag_title">Parameters:</p>
1449
+ <ul class="param">
1450
+
1451
+ <li>
1452
+
1453
+ <span class='name'>unit</span>
1454
+
1455
+
1456
+ <span class='type'>(<tt>String</tt>)</span>
1457
+
1458
+
1459
+
1460
+ &mdash;
1461
+ <div class='inline'><p>the unit to truncate to</p>
1462
+ </div>
1463
+
1464
+ </li>
1465
+
1466
+ <li>
1467
+
1468
+ <span class='name'>exp</span>
1469
+
1470
+
1471
+ <span class='type'>(<tt>String</tt>)</span>
1472
+
1473
+
1474
+
1475
+ &mdash;
1476
+ <div class='inline'><p>the expression to truncate</p>
1477
+ </div>
1478
+
1479
+ </li>
1480
+
1481
+ </ul>
1482
+
1483
+
1484
+ </div><table class="source_code">
1485
+ <tr>
1486
+ <td>
1487
+ <pre class="lines">
1488
+
1489
+
1490
+ 66
1491
+ 67
1492
+ 68
1493
+ 69
1494
+ 70
1495
+ 71
1496
+ 72
1497
+ 73
1498
+ 74
1499
+ 75
1500
+ 76
1501
+ 77
1502
+ 78
1503
+ 79
1504
+ 80
1505
+ 81
1506
+ 82
1507
+ 83
1508
+ 84
1509
+ 85</pre>
1510
+ </td>
1511
+ <td>
1512
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 66</span>
1513
+
1514
+ <span class='kw'>def</span> <span class='id identifier rubyid_truncate_date'>truncate_date</span><span class='lparen'>(</span><span class='id identifier rubyid_unit'>unit</span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
1515
+ <span class='id identifier rubyid_unit'>unit</span> <span class='op'>=</span> <span class='id identifier rubyid_unit'>unit</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span>
1516
+ <span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_unit'>unit</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>week</span><span class='tstring_end'>&#39;</span></span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_adjust_week_start_day?'>adjust_week_start_day?</span>
1517
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:week_start_day</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>_week_start_day</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1518
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
1519
+ <span class='kw'>else</span>
1520
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:truncate_date</span><span class='rparen'>)</span>
1521
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@unit</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_unit'>unit</span><span class='rparen'>)</span>
1522
+ <span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
1523
+
1524
+ <span class='kw'>end</span>
1525
+
1526
+ <span class='comment'># If we are truncating above the timestamp level ie days, years etc
1527
+ </span> <span class='comment'># then we can cast the result to date
1528
+ </span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="#TIMESTAMPABLE_UNITS-constant" title="DWH::Functions::Dates::TIMESTAMPABLE_UNITS (constant)">TIMESTAMPABLE_UNITS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_unit'>unit</span><span class='rparen'>)</span>
1529
+ <span class='id identifier rubyid_res'>res</span>
1530
+ <span class='kw'>else</span>
1531
+ <span class='id identifier rubyid_cast'>cast</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>DATE</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
1532
+ <span class='kw'>end</span>
1533
+ <span class='kw'>end</span></pre>
1534
+ </td>
1535
+ </tr>
1536
+ </table>
1537
+ </div>
1538
+
1539
+ <div class="method_details ">
1540
+ <h3 class="signature " id="week_start_day-instance_method">
1541
+
1542
+ #<strong>week_start_day</strong> &#x21d2; <tt>Object</tt>
1543
+
1544
+
1545
+
1546
+
1547
+
1548
+ </h3><div class="docstring">
1549
+ <div class="discussion">
1550
+ <p>The desired week start day. Could be diff from the db setting.</p>
1551
+
1552
+
1553
+ </div>
1554
+ </div>
1555
+ <div class="tags">
1556
+
1557
+
1558
+ </div><table class="source_code">
1559
+ <tr>
1560
+ <td>
1561
+ <pre class="lines">
1562
+
1563
+
1564
+ 140
1565
+ 141
1566
+ 142</pre>
1567
+ </td>
1568
+ <td>
1569
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 140</span>
1570
+
1571
+ <span class='kw'>def</span> <span class='id identifier rubyid_week_start_day'>week_start_day</span>
1572
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:week_start_day</span><span class='rparen'>)</span>
1573
+ <span class='kw'>end</span></pre>
1574
+ </td>
1575
+ </tr>
1576
+ </table>
1577
+ </div>
1578
+
1579
+ <div class="method_details ">
1580
+ <h3 class="signature " id="week_starts_on_sunday?-instance_method">
1581
+
1582
+ #<strong>week_starts_on_sunday?</strong> &#x21d2; <tt>Boolean</tt>
1583
+
1584
+
1585
+
1586
+
1587
+
1588
+ </h3><div class="docstring">
1589
+ <div class="discussion">
1590
+ <p>Does the week start on sunday?</p>
1591
+
1592
+
1593
+ </div>
1594
+ </div>
1595
+ <div class="tags">
1596
+
1597
+ <p class="tag_title">Returns:</p>
1598
+ <ul class="return">
1599
+
1600
+ <li>
1601
+
1602
+
1603
+ <span class='type'>(<tt>Boolean</tt>)</span>
1604
+
1605
+
1606
+
1607
+ </li>
1608
+
1609
+ </ul>
1610
+
1611
+ </div><table class="source_code">
1612
+ <tr>
1613
+ <td>
1614
+ <pre class="lines">
1615
+
1616
+
1617
+ 157
1618
+ 158
1619
+ 159</pre>
1620
+ </td>
1621
+ <td>
1622
+ <pre class="code"><span class="info file"># File 'lib/dwh/functions/dates.rb', line 157</span>
1623
+
1624
+ <span class='kw'>def</span> <span class='id identifier rubyid_week_starts_on_sunday?'>week_starts_on_sunday?</span>
1625
+ <span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='symbol'>:week_start_day</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>SUNDAY</span><span class='tstring_end'>&#39;</span></span>
1626
+ <span class='kw'>end</span></pre>
1627
+ </td>
1628
+ </tr>
1629
+ </table>
1630
+ </div>
1631
+
1632
+ </div>
1633
+
1634
+ </div>
1635
+
1636
+ <div id="footer">
1637
+ Generated on Fri Aug 22 08:31:21 2025 by
1638
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1639
+ 0.9.37 (ruby-3.4.4).
1640
+ </div>
1641
+
1642
+ </div>
1643
+ </body>
1644
+ </html>