-
Notifications
You must be signed in to change notification settings - Fork 1
/
NUGG_DATETIME.nugg
403 lines (343 loc) · 25.8 KB
/
NUGG_DATETIME.nugg
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<?xml version="1.0" encoding="utf-16"?>
<nugget name="DATETIME">
<CLAS CLSNAME="ZCL_DATETIME" VERSION="1" LANGU="E" DESCRIPT="Datetime class" UUID="519C4F2D238168FCE10000000AF0C46A" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="DKETTLE" CREATEDON="20101209" CHANGEDON="00000000" CHGDANYON="00000000" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="731" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 ">
<publicSection>class ZCL_DATETIME definition
public
create public .
*"* public components of class ZCL_DATETIME
*"* do not include other source files here!!!
public section.
class-data DATE_ATOM type CHAR20 value 'Y-m-d\TH:i:sP'. "#EC NOTEXT . . " .
class-data DATE_COOKIE type CHAR20 value 'l, d-M-y H:i:s T'. "#EC NOTEXT . . " .
class-data DATE_ISO8601 type CHAR20 value 'Y-m-d\TH:i:sO'. "#EC NOTEXT . . " .
class-data DATE_RFC822 type CHAR20 value 'D, d M y H:i:s O'. "#EC NOTEXT . . " .
class-data DATE_RFC850 type CHAR20 value 'l, d-M-y H:i:s T'. "#EC NOTEXT . . " .
class-data DATE_RFC1036 type CHAR20 value 'D, d M y H:i:s O'. "#EC NOTEXT . . " .
class-data DATE_RFC1123 type CHAR20 value 'D, d M Y H:i:s O'. "#EC NOTEXT . . " .
class-data DATE_RFC2822 type CHAR20 value 'D, d M Y H:i:s O'. "#EC NOTEXT . . " .
class-data DATE_RFC3339 type CHAR20 value 'Y-m-d\TH:i:sP'. "#EC NOTEXT . . " .
class-data DATE_RSS type CHAR20 value 'D, d M Y H:i:s O'. "#EC NOTEXT . . " .
class-data DATE_W3C type CHAR20 value 'Y-m-d\TH:i:sP'. "#EC NOTEXT . . " .
methods ADD .
methods CONSTRUCTOR
importing
!TIMESTAMP type TIMESTAMP optional
!TIMEZONE type TZNZONE optional .
methods CREATE_FROM_FORMAT .
methods DIFF .
methods FORMAT
importing
!FORMAT_MASK type CHAR20
returning
value(RETURN) type STRING .
methods GET_OFFSET .
methods GET_TIMESTAMP .
methods GET_TIMEZONE .
methods MODIFY .
methods SET_DATE
importing
!DATE type DATS .
methods SET_ISODATE .
methods SET_TIME
importing
!TIME type TIMS .
methods SET_TIMESTAMP
importing
!TIMESTAMP type TIMESTAMP optional .
methods SET_TIMEZONE
importing
!TIMEZONE type TZNZONE default 'UTC' .
methods SUB .
methods GET_TIMEZONE_OFFSET
importing
!FORMAT_MASK type C default 'P'
returning
value(RETURN) type STRING .</publicSection>
<protectedSection>*"* protected components of class ZCL_DATETIME
*"* do not include other source files here!!!
protected section.</protectedSection>
<privateSection>*"* private components of class ZCL_DATETIME
*"* do not include other source files here!!!
private section.
data _TZ type TZNZONE value 'UTC'. "#EC NOTEXT . . . . . " .
data _TS type DT_SPLIT .
data _WEEK type NUM2 .
data _TIME type TIMS .
data _DATE type DATS .
data _TIMESTAMP type TIMESTAMPL .
data _FORMAT type CHAR20 .
methods GET_MONTH
importing
!IV_MONTH type ABSGR
!IV_CHARS type I default 3
returning
value(RV_MONTH) type STRING .
methods README .</privateSection>
<localImplementation>*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes</localImplementation>
<localTypes>*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature
types: begin of dt_split
, year(4) type n
, month(2) type n
, day(2) type n
, hour(2) type n
, min(2) type n
, sec(2) type n
, subsec(5) type n
, end of dt_split
.</localTypes>
<localMacros>*"* use this source file for any macro definitions you need
*"* in the implementation part of the class</localMacros>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_ATOM" VERSION="1" LANGU="E" DESCRIPT="Atom (example: 2005-08-15T15:52:01+00:00)" EXPOSURE="2" STATE="1" EDITORDER="7 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'Y-m-d\TH:i:sP'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_COOKIE" VERSION="1" LANGU="E" DESCRIPT="HTTP Cookies (example: Monday, 15-Aug-05 15:52:01 UTC)" EXPOSURE="2" STATE="1" EDITORDER="8 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'l, d-M-y H:i:s T'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_ISO8601" VERSION="1" LANGU="E" DESCRIPT="ISO-8601 (example: 2005-08-15T15:52:01+0000)" EXPOSURE="2" STATE="1" EDITORDER="9 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'Y-m-d\TH:i:sO'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_RFC1036" VERSION="1" LANGU="E" DESCRIPT="RFC 1036 (example: Mon, 15 Aug 05 15:52:01 +0000)" EXPOSURE="2" STATE="1" EDITORDER="12 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'D, d M y H:i:s O'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_RFC1123" VERSION="1" LANGU="E" DESCRIPT="RFC 1123 (example: Mon, 15 Aug 2005 15:52:01 +0000)" EXPOSURE="2" STATE="1" EDITORDER="13 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'D, d M Y H:i:s O'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_RFC2822" VERSION="1" LANGU="E" DESCRIPT="RFC 2822 (Mon, 15 Aug 2005 15:52:01 +0000)" EXPOSURE="2" STATE="1" EDITORDER="14 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'D, d M Y H:i:s O'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_RFC3339" VERSION="1" LANGU="E" DESCRIPT="Same as DATE_ATOM" EXPOSURE="2" STATE="1" EDITORDER="15 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'Y-m-d\TH:i:sP'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_RFC822" VERSION="1" LANGU="E" DESCRIPT="RFC 822 (example: Mon, 15 Aug 05 15:52:01 +0000)" EXPOSURE="2" STATE="1" EDITORDER="10 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'D, d M y H:i:s O'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_RFC850" VERSION="1" LANGU="E" DESCRIPT="RFC 850 (example: Monday, 15-Aug-05 15:52:01 UTC)" EXPOSURE="2" STATE="1" EDITORDER="11 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'l, d-M-y H:i:s T'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_RSS" VERSION="1" LANGU="E" DESCRIPT="RSS (Mon, 15 Aug 2005 15:52:01 +0000)" EXPOSURE="2" STATE="1" EDITORDER="16 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'D, d M Y H:i:s O'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="DATE_W3C" VERSION="1" LANGU="E" DESCRIPT="World Wide Web (example: 2005-08-15T15:52:01+00:00)" EXPOSURE="2" STATE="1" EDITORDER="17 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="1" ATTVALUE="'Y-m-d\TH:i:sP'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="_DATE" VERSION="1" LANGU="E" DESCRIPT="Date" EXPOSURE="0" STATE="1" EDITORDER="5 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="DATS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="_FORMAT" VERSION="1" LANGU="E" DESCRIPT="current format for output" EXPOSURE="0" STATE="1" EDITORDER="18 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="CHAR20" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="_TIME" VERSION="1" LANGU="E" DESCRIPT="Field of type TIMS" EXPOSURE="0" STATE="1" EDITORDER="4 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="TIMS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="_TIMESTAMP" VERSION="1" LANGU="E" DESCRIPT="UTC Time Stamp (long form)" EXPOSURE="0" STATE="1" EDITORDER="6 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="TIMESTAMPL" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="_TS" VERSION="1" LANGU="E" DESCRIPT="time split into elements" EXPOSURE="0" STATE="1" EDITORDER="2 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="DT_SPLIT" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="_TZ" VERSION="1" LANGU="E" DESCRIPT="timezone" EXPOSURE="0" STATE="1" EDITORDER="1 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="0" ATTVALUE="'UTC'" ATTEXPVIRT="0" TYPTYPE="1" TYPE="TZNZONE" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_DATETIME" CMPNAME="_WEEK" VERSION="1" LANGU="E" DESCRIPT="iso-8601 week number" EXPOSURE="0" STATE="1" EDITORDER="3 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="NUM2" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="731" TYPESRC_LENG="0 "/>
<method CLSNAME="ZCL_DATETIME" CMPNAME="ADD" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method ADD.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="CONSTRUCTOR" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="2 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="2" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="CONSTRUCTOR" SCONAME="TIMESTAMP" VERSION="1" LANGU="E" DESCRIPT="UTC Time Stamp in Short Form (YYYYMMDDhhmmss)" CMPTYPE="1" MTDTYPE="2" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TIMESTAMP" PAROPTIONL="X"/>
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="CONSTRUCTOR" SCONAME="TIMEZONE" VERSION="1" LANGU="E" DESCRIPT="Time Zone" CMPTYPE="1" MTDTYPE="2" EDITORDER="2 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TZNZONE" PAROPTIONL="X"/>
<source>METHOD constructor.
*!--------------------------------------------------------------------+
*! This code has been supplied by Nigel James of Square Cloud Pty Ltd
*! It has been released to the public domain and is available to use.
*! Please contact [email protected] for more information
*!--------------------------------------------------------------------+
IF timezone IS SUPPLIED.
set_timezone( timezone ).
ENDIF.
set_timestamp( timestamp ).
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="CREATE_FROM_FORMAT" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="3 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method CREATE_FROM_FORMAT.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="DIFF" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="4 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method DIFF.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="FORMAT" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="5 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="FORMAT" SCONAME="FORMAT_MASK" VERSION="1" LANGU="E" DESCRIPT="format mask to format the time" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="CHAR20"/>
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="FORMAT" SCONAME="RETURN" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="STRING"/>
<source>method FORMAT.
* the aim here is to format the timestamp with the format mask that is passed to this method.
* see class CL_ABAP_TSTMP and CL_ABAP_DATFM
* the formatting characters are taken from
* http://php.net/manual/en/function.date.php which are pretty standard from unix
data: len type i
, buffer(60) type c
, counter type i
, char type c
, tmp type string
, month type string
.
len = strlen( format_mask ).
counter = 0.
do len times.
char = format_mask+counter(1).
case char.
** year
when 'Y'. " four year date
concatenate buffer _ts-year into buffer.
when 'y'. "two year date
concatenate buffer _ts-year+2(2) into buffer.
* o and L not yet implemented
** month
when 'm'. " numeric month with leading zeros
concatenate buffer _ts-month into buffer.
* F, M, n, t not yet implemented
when 'M'. " three letter month
month = get_month( iv_month = _ts-month iv_chars = 3 ).
concatenate buffer month into buffer.
** day
when 'd'. " numeric day with leading zeros
concatenate buffer _ts-day into buffer.
* D, j, l, N, S, w, z not yet implemented
** week
when 'W'. " ISO-8601 week number of year, weeks starting on Monday
concatenate buffer _week into buffer.
** hour
when 'H'. "24 hour time with leading zeros
concatenate buffer _ts-hour into buffer.
when 'a' or 'A'. " am or pm
if _ts-hour < 12.
tmp = 'am'.
else.
tmp = 'pm'.
endif.
if char = 'A'.
translate tmp to upper case.
endif.
concatenate buffer tmp into buffer.
* g, G, h, not yet implemented
** minute
when 'i'. "minutes with leading zeros
concatenate buffer _ts-min into buffer.
** second
when 's'. "seconds with leading zeros
concatenate buffer _ts-sec into buffer.
** subsecond
when 'u'. "sub second part of timestamp
concatenate buffer _ts-subsec into buffer.
** timezone
when 'P'. "timezone offset in hours and minutes eg +10:00
tmp = get_timezone_offset( ).
concatenate buffer tmp into buffer.
when 'T'. "timezone name from table ttzz
concatenate buffer _tz into buffer.
** space handling
when space. " insert a '~' into buffer and remove at end
concatenate buffer '~' into buffer.
** escape character \
when '\'.
counter = counter + 1.
char = format_mask+counter(1).
concatenate buffer char into buffer.
** default
when others.
concatenate buffer char into buffer.
endcase.
counter = counter + 1.
enddo.
* replace all occurrences of '~' in buffer with ' ' in character mode.
translate buffer using '~ '.
* concatenate 'year ' _ts-year 'month ' _ts-month 'day ' _ts-day
* 'hour ' _ts-hour 'min ' _ts-min 'sec ' _ts-sec
* into return.
return = buffer.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="GET_MONTH" VERSION="1" LANGU="E" EXPOSURE="0" STATE="1" EDITORDER="17 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="GET_MONTH" SCONAME="IV_MONTH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="ABSGR"/>
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="GET_MONTH" SCONAME="IV_CHARS" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="I" PARVALUE="3"/>
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="GET_MONTH" SCONAME="RV_MONTH" VERSION="1" LANGU="E" DESCRIPT="Three-digit character field for IDocs" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="STRING"/>
<source>METHOD get_month.
DATA:
month TYPE monam
.
SELECT SINGLE monam
INTO month
FROM t015m
WHERE spras = sy-langu
AND monum = iv_month.
IF iv_chars IS NOT SUPPLIED OR iv_chars = 0.
rv_month = month.
ELSE.
rv_month = month(iv_chars).
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="GET_OFFSET" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="6 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method GET_OFFSET.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="GET_TIMESTAMP" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="7 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method GET_TIMESTAMP.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="GET_TIMEZONE" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="8 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method GET_TIMEZONE.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="GET_TIMEZONE_OFFSET" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="16 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="GET_TIMEZONE_OFFSET" SCONAME="FORMAT_MASK" VERSION="1" LANGU="E" DESCRIPT="type of offset" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="C" PARVALUE="'P'"/>
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="GET_TIMEZONE_OFFSET" SCONAME="RETURN" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="STRING"/>
<source>method GET_TIMEZONE_OFFSET.
types: begin of diff_ty
, utcsign type TZNUTCSIGN
, utcdiff TYPE tznutcdiff
, end of diff_ty
.
DATA: diff TYPE diff_ty
.
SELECT SINGLE r~utcsign r~utcdiff
FROM ( ttzz AS z INNER JOIN ttzr AS r ON z~zonerule = r~zonerule )
INTO diff
WHERE z~tzone = me->_tz.
** only working for atom type right now - this needs to change for other expressions of timezone.
concatenate diff-utcsign diff-utcdiff+0(2) ':' diff-utcdiff+2(2) into return.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="MODIFY" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="9 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method MODIFY.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="README" VERSION="1" LANGU="E" DESCRIPT="Read me for information about this class" EXPOSURE="0" STATE="1" EDITORDER="18 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method README.
*!--------------------------------------------------------------------+
*! This code has been supplied by Nigel James of Square Cloud Pty Ltd
*! It has been released to the public domain and is available to use.
*! Please contact [email protected] for updates or
*! more information
*!--------------------------------------------------------------------+
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="SET_DATE" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="10 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="SET_DATE" SCONAME="DATE" VERSION="1" LANGU="E" DESCRIPT="Field of type DATS" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="DATS"/>
<source>method SET_DATE.
_date = date.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="SET_ISODATE" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="11 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method SET_ISODATE.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="SET_TIME" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="12 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="SET_TIME" SCONAME="TIME" VERSION="1" LANGU="E" DESCRIPT="Field of type TIMS" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TIMS"/>
<source>method SET_TIME.
_time = time.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="SET_TIMESTAMP" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="13 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="SET_TIMESTAMP" SCONAME="TIMESTAMP" VERSION="1" LANGU="E" DESCRIPT="UTC Time Stamp in Long Form (YYYYMMDDhhmmssmmmuuun)" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDBY="NJJ719" CHANGEDON="20130522" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TIMESTAMP" PAROPTIONL="X"/>
<source>method SET_TIMESTAMP.
if me->_tz is initial.
set_timezone( ).
endif.
* by default create the timestamp as it is now
if timestamp is not supplied.
get time stamp field me->_timestamp.
else.
_timestamp = timestamp.
endif.
convert time stamp me->_timestamp time zone me->_tz into date me->_date time me->_time.
me->_ts = me->_date.
me->_ts+8 = me->_time.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="SET_TIMEZONE" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="14 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_DATETIME" CMPNAME="SET_TIMEZONE" SCONAME="TIMEZONE" VERSION="1" LANGU="E" DESCRIPT="Time Zone" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TZNZONE" PARVALUE="'UTC'"/>
<source>method SET_TIMEZONE.
if timezone is not supplied.
me->_tz = 'UTC'.
else.
me->_tz = timezone.
endif.
endmethod.</source>
</method>
<method CLSNAME="ZCL_DATETIME" CMPNAME="SUB" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="15 " DISPID="0 " AUTHOR="NJJ719" CREATEDON="20130522" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="731" BCMTDCAT="00" BCMTDSYN="0">
<source>method SUB.
endmethod.</source>
</method>
</CLAS>
</nugget>