1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-05 09:56:22 +00:00

Add IIFE.

This commit is contained in:
hacksalot 2016-01-18 14:10:25 -05:00
parent 712cba57b8
commit c8d8e566f8

View File

@ -1,9 +1,11 @@
/**
The HackMyResume date representation.
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
@module fluent-date.js
@license MIT. See LICENSE.md for details.
@module core/fluent-date
*/
(function(){
var moment = require('moment');
/**
@ -26,7 +28,10 @@ function FluentDate( dt ) {
this.rep = this.fmt( dt );
}
FluentDate/*.prototype*/.fmt = function( dt ) {
FluentDate/*.prototype*/.fmt = function( dt, throws ) {
throws = (throws === undefined || throws === null) || throws;
if( (typeof dt === 'string' || dt instanceof String) ) {
dt = dt.toLowerCase().trim();
if( /^(present|now|current)$/.test(dt) ) { // "Present", "Now"
@ -63,7 +68,9 @@ FluentDate/*.prototype*/.fmt = function( dt ) {
var mt = moment( dt );
if(mt.isValid())
return mt;
if( throws )
throw 'Invalid date format encountered.';
return null;
}
}
else {
@ -72,7 +79,9 @@ FluentDate/*.prototype*/.fmt = function( dt ) {
}
else if( dt.isValid && dt.isValid() )
return dt;
if( throws )
throw 'Unknown date object encountered.';
return null;
}
};
@ -82,3 +91,5 @@ moment.monthsShort().forEach(function(m,idx){abbr[m.toLowerCase()]=idx+1;});
abbr.sept = 9;
module.exports = FluentDate;
}());