lkiesow / erlang-datetime Goto Github PK
View Code? Open in Web Editor NEWErlang module providing import and export functions for datetime strings specified by RFC822/RFC2822/RSS to erlang datetime tuples
License: Other
Erlang module providing import and export functions for datetime strings specified by RFC822/RFC2822/RSS to erlang datetime tuples
License: Other
Module description ================== This module provides simple import and export functions for datetime strings specified by RFC822, RFC2822 and the RSS specification to erlang datetime tuples as returned for example by erlang:universaltime() or erlang:localtime(). datetime_encode =============== Convert a erlang datetime struct to its string representation according to either RFC822 or the RSS specification. datetime_encode( DateTime, TimeZone, SpecType ) | | +------- Defaults to 'rfc2822' | +------- Defaults to 'GMT' +------- Defaults to erlang:universaltime() DateTime must be of the form {{Year,Month,Day},{Hour,Minute,Second}}. This form is returned for example by the erlang functions universaltime() or localtime(). TimeZone has to be a zone according to RFC822. Additional time zones may be accepted in the future. SpecType can be either 'rfc822' or 'rss'. Both specifications are basically the same except for the length of the year. RSS supports both, two and four digit years while rfc882 only accepts two digit year representation. Some specifications of rfc2882 marked as obsolete and comments are not supported as they are basically never used in the real world. datetime_decode =============== Converts a DateTime string according to rfc822 or RSS specifications into an erlang datetime tupel. The first parameter is the datetime string, the second specifies the handling of years represented as two digits. According to the RFC822 a year is only represented by its two last digits. There are some methods provided for expanding those short year representations to a full year. You can choose between the following expansion rules. The default rule is 'smart'. smart If the two digit year is less or equal of the two last digits of the current year, assume that the date is from the current century. Otherwise assume that the date is from last century. Example (Current year is 2012): 12 will become 2012 34 will become 1934 05 will become 2005 current_century It is assumed that all dates are from this century. no_alternation No alternation is done. Thus two digit years stay as they are. DIGIT DIGIT may be any integer. Using this method you can specify a concrete century. This number is basically added to the two digit year. Thus 34 with DIGIT = 1800 will become 1834.
I'm looking at RFC822 from http://www.faqs.org/rfcs/rfc822.html, and my reading is that the date format goes "day month year", but your code seems to be doing "year month day".
Is this intentional? Am I looking at the wrong spec?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.