Replies: 4 comments 4 replies
-
Thanks for the feedback. |
Beta Was this translation helpful? Give feedback.
1 reply
-
The standard library currently encompasses no I/O with an external environment, and that's a nice property to preserve. I'm opposed to breaking it with introduction of a date or similar function. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Great idea 👍 this would be handy |
Beta Was this translation helpful? Give feedback.
0 replies
-
Challenges when implementing date-related functions
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A
date()
function accepts a date/time string and output unix timestamp, string or object.First argument accepts followings.
date('2023-01-01T00:00:00Z')
date('1 days ago')
date('2 hours ago')
date('now')
date(1672531200)
date({ year:2023, month:1, date:1, hours:0, minutes:0, seconds:0, offsetMinutes:0})
Second argument accepts output format and time zone as object properties.
The output format is specified by the
format
property.date('2023-01-01T00:00:00Z', { format: 'timestamp' })
1672531200
date('2023-01-01T00:00:00Z', { format: 'seconds' })
date('2023-01-01T00:00:00Z', { format: 'date' })
date('2023-01-01T00:00:00Z', { format: 'object' })
{ year:2023, month:1, date:1, hours:0, minutes:0, seconds:0, offsetMinutes:0, timestamp:1672531200, value:"2023-01-01T00:00:00Z"}
date('2023-01-01T00:00:00Z', { format: format_string })
%Y-%d-%m %H:%M:%S
Default format is
'timestamp'
.When specify
{ format: 'object' }
, output object the first argument invalue
property.The output time zone is specified by the
out_timezone
property.date('2023-01-01T00:00:00Z', { format: 'seconds', out_timezone: '09:00' })
The
out_timezone
may be ignored in someformat
.If
out_timezone
is not specified, return in the same time zone as first argument.The input time zone is specified by the
in_timezone
property.date('2023-01-01T00:00:00', { format: 'seconds', in_timezone: '09:00' })
The
in_timezone
is ignored if time zone is indicated by first argument.If time zone is not indicated by first argument and
in_timezone
is not specified, use local time zone.Example
Beta Was this translation helpful? Give feedback.
All reactions