smallex v0.1.4 Dt
DateTime utiity.
Link to this section Summary
Functions
Hyphen to slash
Slash to hyphen
Get datetime from string/tuple
To JST string from UTC
To yyyy/mm string
To yyyy/mm/dd string
Link to this section Functions
Link to this function
add_days(dt, days)
Link to this function
cut_second(str, cut_second \\ :cut_second)
Link to this function
diff_ymd_string(to, from, units)
Link to this function
format_from_string(dt_str, format_str, with_status \\ :no_status)
Link to this function
format_to_string(dt, format_str, with_status \\ :no_status)
Link to this function
hyphen_to_slash(str)
Hyphen to slash
Examples
iex> Dt.hyphen_to_slash( "2018-01-02 03:04:05" )
"2018/01/02 03:04:05"
iex> Dt.hyphen_to_slash( "2018/01/02 03:04:05" )
"2018/01/02 03:04:05"
Link to this function
list_ymd(to, from)
Link to this function
now_timestamp(date_sep \\ "", separate \\ "", time_sep \\ "", second_sep \\ "")
Link to this function
now_ym()
Link to this function
now_ymd()
Link to this function
slash_to_hyphen(str)
Slash to hyphen
Examples
iex> Dt.slash_to_hyphen( "2018/01/02 03:04:05" )
"2018-01-02 03:04:05"
iex> Dt.slash_to_hyphen( "2018-01-02 03:04:05" )
"2018-01-02 03:04:05"
Link to this function
to_datetime(str)
Get datetime from string/tuple
Examples
iex> Dt.to_datetime( "2018/1" )
~N[2018-01-01 00:00:00]
iex> Dt.to_datetime( "2018/ 1" )
~N[2018-01-01 00:00:00]
iex> Dt.to_datetime( "2018/01" )
~N[2018-01-01 00:00:00]
iex> Dt.to_datetime( "2018/1/2" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "2018/1/2 3:4" )
~N[2018-01-02 03:04:00]
iex> Dt.to_datetime( "2018/1/2 3:4:5" )
~N[2018-01-02 03:04:05]
iex> Dt.to_datetime( "2018/1/2 03:04" )
~N[2018-01-02 03:04:00]
iex> Dt.to_datetime( "2018/1/2 03:04:05" )
~N[2018-01-02 03:04:05]
iex> Dt.to_datetime( "2018/ 1/ 2" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "2018/1/ 2" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "2018/01/ 2" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "2018/01/02" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "2018/01/02 23:44" )
~N[2018-01-02 23:44:00]
iex> Dt.to_datetime( "2018/01/02 23:44:09" )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( "2018/01/02 23:44:09.005" )
~N[2018-01-02 23:44:09.005]
iex> Dt.to_datetime( "2018-01-02" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "2018-01-02 23:44" )
~N[2018-01-02 23:44:00]
iex> Dt.to_datetime( "2018-01-02 23:44:09" )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( "2018-01-02 23:44:09.005" )
~N[2018-01-02 23:44:09.005]
iex> Dt.to_datetime( "Jan-02-2018" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "Jan-02-2018 23:44" )
~N[2018-01-02 23:44:00]
iex> Dt.to_datetime( "Jan-02-2018 23:44:09" )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( "Jan-02-2018 23:44:09.005" )
~N[2018-01-02 23:44:09.005]
iex> Dt.to_datetime( "Jan-02-18" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "Jan-02-18 23:44" )
~N[2018-01-02 23:44:00]
iex> Dt.to_datetime( "Jan-02-18 23:44:09" )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( "Jan-02-18 23:44:09.005" )
~N[2018-01-02 23:44:09.005]
#iex> Dt.to_datetime( "Jan-02-98" )
#~N[1998-01-02 00:00:00]
#iex> Dt.to_datetime( "Jan-02-98 23:44" )
#~N[1998-01-02 23:44:00]
#iex> Dt.to_datetime( "Jan-02-98 23:44:09" )
#~N[1998-01-02 23:44:09]
#iex> Dt.to_datetime( "Jan-02-98 23:44:09.005" )
#~N[1998-01-02 23:44:09.005]
iex> Dt.to_datetime( "January-02-2018" )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( "January-02-2018 23:44" )
~N[2018-01-02 23:44:00]
iex> Dt.to_datetime( "January-02-2018 23:44:09" )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( "January-02-2018 23:44:09.005" )
~N[2018-01-02 23:44:09.005]
iex> Dt.to_datetime( "2018-01-02 23:44:09Z" )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( "2018-01-02T23:44:09Z" )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( { 2018, 1, 2 } )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( { { 2018, 1, 2 }, { 23, 44, 9 } } )
~N[2018-01-02 23:44:09]
iex> Dt.to_datetime( ~D[2018-01-02] )
~N[2018-01-02 00:00:00]
iex> Dt.to_datetime( ~N[2018-01-02 23:10:07] )
~N[2018-01-02 23:10:07]
Link to this function
to_jst(utc, cut_second \\ :cut_second)
To JST string from UTC
Examples
iex> Dt.to_jst( "2018/1/2 10:23:45" )
"2018/01/02 19:23"
iex> Dt.to_jst( "2018/1/2 15:23:45" )
"2018/01/03 00:23"
Link to this function
to_timestamp_string(dt, date_sep \\ "", between_sep \\ "", time_sep \\ "", second_sep \\ "")
Link to this function
ym_string(dt)
To yyyy/mm string
Examples
iex> Dt.ym_string( ~N[2018-01-02 03:04:05] )
"2018/01"
Link to this function
ymd_string(dt)
To yyyy/mm/dd string
Examples
iex> Dt.ymd_string( ~N[2018-01-02 03:04:05] )
"2018/01/02"