@@ -222,7 +222,8 @@ Defined as:
222
222
223
223
Returns the time zone in hours as an offset from UTC.
224
224
225
- say DateTime.new('2015-12-24T12:23:00+0200').offset-in-hours; # OUTPUT: «2»
225
+ = for code
226
+ say DateTime.new('2015-12-24T12:23:00+0200').offset-in-hours; # OUTPUT: «2»
226
227
227
228
= head2 method Str
228
229
@@ -231,10 +232,12 @@ Defined as:
231
232
method Str(DateTime:D: --> Str:D)
232
233
233
234
Returns a string representation of the invocant, as done by
234
- L < the formatter|/type/Dateish#method_formatter > . If no formatter was specified, an
235
- ISO 8601 timestamp will be returned.
235
+ L < the formatter|/type/Dateish#method_formatter > .
236
+ If no formatter was specified, an ISO 8601 timestamp will be returned.
236
237
237
- say DateTime.new('2015-12-24T12:23:00+0200').Str; # OUTPUT: «2015-12-24T12:23:00+02:00»
238
+ = for code
239
+ say DateTime.new('2015-12-24T12:23:00+0200').Str;
240
+ # OUTPUT: «2015-12-24T12:23:00+02:00»
238
241
239
242
= head2 method Instant
240
243
@@ -258,7 +261,8 @@ Returns the date and time as a POSIX/UNIX timestamp (seconds since the Epoch,
258
261
If C < $ignore-timezone > is C < True > , the C < DateTime > object will be treated as if
259
262
the timezone offset is zero.
260
263
261
- say DateTime.new('2015-12-24T12:23:00Z').posix; # OUTPUT: «1450959780»
264
+ = for code
265
+ say DateTime.new('2015-12-24T12:23:00Z').posix; # OUTPUT: «1450959780»
262
266
263
267
= head2 method later
264
268
@@ -281,7 +285,8 @@ the C<later> and C<earlier> methods.
281
285
The C < :2nd > form of colonpairs can be used as a compact and self-documenting
282
286
way of specifying the delta:
283
287
284
- say DateTime.new('2015-12-24T12:23:00Z').later(:2years); # OUTPUT: «2017-12-24T12:23:00Z»
288
+ say DateTime.new('2015-12-24T12:23:00Z').later(:2years);
289
+ # OUTPUT: «2017-12-24T12:23:00Z»
285
290
286
291
Since addition of several different time units is not commutative, only one
287
292
unit may be passed.
@@ -297,7 +302,8 @@ actually exists for that time, seconds will be set to C<59>:
297
302
say DateTime.new('2008-12-31T23:59:60Z').later: :1day;
298
303
# OUTPUT: «2009-01-01T23:59:59Z»
299
304
300
- Negative offsets are allowed, though L < earlier|/routine/earlier > is more idiomatic for that.
305
+ Negative offsets are allowed, though L < earlier|/routine/earlier > is more
306
+ idiomatic for that.
301
307
302
308
= head2 method earlier
303
309
@@ -306,8 +312,9 @@ Defined as:
306
312
method earlier(DateTime:D: *%unit)
307
313
308
314
Returns a DateTime object based on the current one, but with a time delta
309
- towards the past applied. Unless the given unit is C < second > or C < seconds > ,
310
- the given value will be converted to an L < Int|/type/Int > . See L < #method later > for usage.
315
+ towards the past applied. Unless the given unit is C < second > or C < seconds > , the
316
+ given value will be converted to an L < Int|/type/Int > . See L < #method later > for
317
+ usage.
311
318
312
319
my $d = DateTime.new(date => Date.new('2015-02-27'));
313
320
say $d.earlier(month => 1).earlier(:2days); # OUTPUT: «2015-01-25T00:00:00Z»
@@ -349,8 +356,9 @@ Defined as:
349
356
350
357
Converts the invocant to L « C < Date > |/type/Date» .
351
358
352
- say DateTime.new("2012-02-29T12:34:56.946314Z").Date; # OUTPUT: «2012-02-29»
353
- say DateTime.Date; # OUTPUT: «(Date)»
359
+ = for code
360
+ say DateTime.new("2012-02-29T12:34:56.946314Z").Date; # OUTPUT: «2012-02-29»
361
+ say DateTime.Date; # OUTPUT: «(Date)»
354
362
355
363
= head2 method DateTime
356
364
@@ -360,8 +368,10 @@ Defined as:
360
368
361
369
Returns the invocant.
362
370
363
- say DateTime.new("2012-02-29T12:34:56.946314Z").DateTime; # 2012-02-29T12:34:56.946314Z
364
- say DateTime.DateTime; # OUTPUT: «(DateTime)»
371
+ say DateTime.new("2012-02-29T12:34:56.946314Z").DateTime;
372
+ # OUTPUT: «2012-02-29T12:34:56.946314Z»
373
+ say DateTime.DateTime;
374
+ # OUTPUT: «(DateTime)»
365
375
366
376
= head2 method utc
367
377
@@ -371,16 +381,18 @@ Defined as:
371
381
372
382
Returns a DateTime object for the same time, but in time zone UTC.
373
383
374
- say DateTime.new('2015-12-24T12:23:00+0200').utc; # OUTPUT: «2015-12-24T10:23:00Z»
384
+ say DateTime.new('2015-12-24T12:23:00+0200').utc;
385
+ # OUTPUT: «2015-12-24T10:23:00Z»
375
386
376
387
= head2 method in-timezone
377
388
378
389
Defined as:
379
390
380
391
method in-timezone(DateTime:D: Int(Cool) $timezone = 0 --> DateTime:D)
381
392
382
- Returns a DateTime object for the same time, but in the specified C < $timezone > , which is
383
- the offset B < in seconds > from L < GMT|https://en.wikipedia.org/wiki/Greenwich_Mean_Time > .
393
+ Returns a DateTime object for the same time, but in the specified C < $timezone > ,
394
+ which is the offset B < in seconds > from
395
+ L < GMT|https://en.wikipedia.org/wiki/Greenwich_Mean_Time > .
384
396
385
397
say DateTime.new('2015-12-24T12:23:00Z').in-timezone(3600 + 1800); # OUTPUT: «2015-12-24T13:53:00+0130»
386
398
0 commit comments