Skip to content

Instantly share code, notes, and snippets.

@OnorioCatenacci
Last active August 29, 2015 14:08
Show Gist options
  • Save OnorioCatenacci/3490f89b107c6700935f to your computer and use it in GitHub Desktop.
Save OnorioCatenacci/3490f89b107c6700935f to your computer and use it in GitHub Desktop.
#Two small, quick date utility functions. Convert a wxDateTime (from wxErlang) to a YYYYMMDD string. NB: assumes year is post 1000 CE.
defp wxDatetime_to_string({{year,month,day},{_hour,_minute,_second}}), do: "#{year}#{zero_padding(month,2)}#{zero_padding(day,2)}"
#Pad a string out with a specified number of leading zeroes.
defp zero_padding(string,len), do: String.rjust(to_string(string), len, ?0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment