Git Product home page Git Product logo

erlang_localtime's Introduction

Public exports

  • utc_to_local(DateTime, Timezone) - converts UTC time to local according to specified Timezone
  • local_to_utc(DateTime, Timezone) - converts local time to UTC
  • local_to_local(DateTime, TimezoneFrom, TimezoneTo) - converts local time to local
  • tz_name(DateTime, Timezone) - returns a timezone name (E.g. MSK, MSD, etc)
  • tz_shift(DateTime, Timezone) - returns time difference between local datetime and GMT
  • tz_shift(DateTime, TimezoneFrom, TimezoneTo) - returns time difference between local datetime and required timezone Where DateTime = {date(), time()} TimeZone(To, From) = String(). E.g. “Europe/Moscow”, “America/NewYork”. Or abbreviations "MSK", "MSD", etc. Note: abbreviation is just used to find appropriate timezone name. If you want to convert "MSK" -> "PDT", but source timezone is not in daylight saving, it will be corrected by library and "MSK" -> "PST" conversion will be made.

Examples of usage

Converts UTC time to local one

localtime:utc_to_local({{2010, 7, 22}, {17, 56, 23}, "Europe/Moscow").

{{2010,10,10},{21,56,23}}

Converts local time to UTC one

localtime:local_to_utc({{2010, 10, 10}, {21, 56, 23}}, "Europe/Moscow").

{{2010,10,10},{17,56,23}}

Converts time from one local timezone to another local one

localtime:local_to_local({{2010, 10, 10}, {21, 56, 23}}, "Europe/Moscow", "Australia/Sydney").

{{2010,10,11},{3,56,23}}

Returns timezone name

localtime:tz_name({{2010, 10, 10}, {21, 56, 23}}, "Europe/Moscow").

{"MSK","MSK"}

localtime:tz_name({{2010,10,11},{3,56,23}}, "Australia/Sydney").

{"EST","EST"}

Calculates time difference between UTC and local one

localtime:tz_shift({{2013, 01, 22}, {18, 17, 00}}, "Europe/Moscow").

{'+',4,0}

localtime:tz_shift({{2013, 01, 22}, {18, 17, 00}}, "America/New York").

{'-',5,0}

Calculates time difference between two local timezones

localtime:tz_shift({{2013, 01, 22}, {18, 17, 00}}, "America/New York", "Europe/Moscow").

{'+',9,0}

erlang_localtime's People

Contributors

choptastic avatar desoulter avatar nisbus 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.