Code Monkey home page Code Monkey logo

strftimerl's Introduction

strftimerl

Erlang implementation of strftime. This library implements most of the strftime format specifiers. It currently does not support the any of the locale related text specifiers (day of week name, month name, etc), %U, %W, timezone specifiers, or the locale preferred date specifiers (%x, %X).

Version Downloads Build Status codecov.io

format/2

format(Value, Datetime) -> string()
  • Value = string()
  • Datetime = datetime()

Format a date and time. Supported conversion specifications include:

Specifier Meaning
%C The century number (year/100) as a 2-digit integer.
%d The day of the month as a decimal number (range 01 to 31).
%D Equivalent to %m/%d/%y.
%F Equivalent to %Y-%m-%d.
%G The ISO 8601 week-based year with century as a decimal number.
%g Like %G, but without century, that is, with a 2-digit year (00-99).
%H The hour as a decimal number using a 24-hour clock (range 00 to 23).
%I The hour as a decimal number using a 12-hour clock (range 01 to 12).
%j The day of the year as a decimal number (range 001 to 366).
%k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H)
%l The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I)
%m The month as a decimal number (range 01 to 12).
%M The minute as a decimal number (range 00 to 59).
%n A newline character.
%p Either "AM" or "PM" according to the given time value. Noon is treated as "PM" and midnight as "AM".
%P Like %p but in lowercase: "am" or "pm".
%r The time in a.m. or p.m. notation. This is equivalent to %I:%M:%S %p.
%R The time in 24-hour notation (%H:%M). For a version including the seconds, see %T below.
%s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
%S The second as a decimal number (range 00 to 60). The range is up to 60 to allow for occasional leap seconds.โ€จ
%t A tab character.
%T The time in 24-hour notation (%H:%M:%S).
%u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
%V The ISO 8601 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the new year.
%w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
%y The year as a decimal number without a century (range 00 to 99).
%Y The year as a decimal number including the century.

Examples

Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V6.4  (abort with ^G)
1> strftimerl:format("%Y-%m-%d %H:%M:%S", calendar:universal_time()).
"2015-08-17 22:02:26"
2> strftimerl:format("%s", calendar:universal_time()).
"1439848958"
3> strftimerl:format("%D", calendar:universal_time()).
"08/17/2015"
4> io:format("~s~n", [strftimerl:format("%Y-%m-%d%n%I:%M %P", calendar:universal_time())]).
2015-08-17
10:04 pm
ok    

strftimerl's People

Contributors

gmr avatar hodak avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.