@@ -189,6 +189,24 @@ function DateTime.toIsoDate(self: DateTime): string
189189 return nil :: any
190190end
191191
192+ --[=[
193+ @within DateTime
194+ @tag Method
195+
196+ Formats this `DateTime` as an RFC 2822 date-time string.
197+
198+ Some examples of RFC 2822 date-time strings are:
199+
200+ - `Fri, 21 Nov 1997 09:55:06 -0600`
201+ - `Tue, 1 Jul 2003 10:52:37 +0200`
202+ - `Mon, 23 Dec 2024 01:58:48 GMT`
203+
204+ @return string -- The RFC 2822 formatted string
205+ ]=]
206+ function DateTime .toRfc2822 (self : DateTime ): string
207+ return nil :: any
208+ end
209+
192210--[=[
193211 @within DateTime
194212 @tag Method
@@ -255,6 +273,9 @@ export type DateTime = typeof(DateTime)
255273 -- Formats the current moment in time as an ISO 8601 string
256274 print (now :toIsoDate ())
257275
276+ -- Formats the current moment in time as an RFC 2822 string
277+ print (now :toRfc2822 ())
278+
258279 -- Formats the current moment in time, using the local
259280 -- time, the French locale, and the specified time string
260281 print (now :formatLocalTime ("%A, %d %B %Y" , "fr" ))
395416 @tag Constructor
396417
397418 Creates a new `DateTime` from an ISO 8601 date-time string.
419+ This function behaves the same as `fromRfc3339`.
398420
399421 ### Errors
400422
@@ -414,4 +436,52 @@ function dateTime.fromIsoDate(isoDate: string): DateTime
414436 return nil :: any
415437end
416438
439+ --[=[
440+ @within DateTime
441+ @tag Constructor
442+
443+ Creates a new `DateTime` from an RFC 3339 date-time string.
444+
445+ ### Errors
446+
447+ This constructor is fallible and may throw an error if the given
448+ string does not strictly follow the RFC 3339 date-time string format.
449+
450+ Some examples of valid RFC 3339 date-time strings are:
451+
452+ - `2020-02-22T18:12:08Z`
453+ - `2000-01-31T12:34:56+05:00`
454+ - `1970-01-01T00:00:00.055Z`
455+
456+ @param rfc3339Date -- An RFC 3339 formatted string
457+ @return DateTime -- The new DateTime object
458+ ]=]
459+ function dateTime .fromRfc3339 (rfc3339Date : string ): DateTime
460+ return nil :: any
461+ end
462+
463+ --[=[
464+ @within DateTime
465+ @tag Constructor
466+
467+ Creates a new `DateTime` from an RFC 2822 date-time string.
468+
469+ ### Errors
470+
471+ This constructor is fallible and may throw an error if the given
472+ string does not strictly follow the RFC 2822 date-time string format.
473+
474+ Some examples of valid RFC 2822 date-time strings are:
475+
476+ - `Fri, 21 Nov 1997 09:55:06 -0600`
477+ - `Tue, 1 Jul 2003 10:52:37 +0200`
478+ - `Mon, 23 Dec 2024 01:58:48 GMT`
479+
480+ @param rfc2822Date -- An RFC 2822 formatted string
481+ @return DateTime -- The new DateTime object
482+ ]=]
483+ function dateTime .fromRfc2822 (rfc2822Date : string ): DateTime
484+ return nil :: any
485+ end
486+
417487return dateTime
0 commit comments