"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
Tuesday, July 4, 2017
6 Ways Social Media Can Help Build Customer Loyalty (Infographic)
[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]
by Irfan Ahmad via Digital Information World
Kids WordPress Theme
Baby Shop & Kids Store WooCommerce Theme
by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery
Breves Bandeiras
O que é possível afirmar hoje numa bandeira?
by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery
ASOVIEW Inc.
corporate site
by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery
Marshall
by Rob Hope via One Page Love
Introduction to date-fns – a Lightweight JavaScript Date Library
Working with dates in JavaScript is a pain. Native date methods are often verbose and occasionally inconsistent — something which also makes them error-prone. But good news is at hand. There are several libraries that exist to take the pain out of date manipulation. These libraries are to JavaScript dates, what jQuery is to the native DOM API.
Let me give you an example. This is the accepted answer to a Stack Overflow question asking how to get last day of the month:
var t = new Date();
alert( new Date(t.getFullYear(), t.getMonth() + 1, 0, 23, 59, 59) );
Of course that works, but it's not immediately obvious what the numbers after getMonth
represent. Now contrast that with the considerably more readable:
const today = new Date();
console.log( lastDayOfMonth(today) );
That lastDayOfMonth
method is one provided by date-fns, a self-proclaimed comprehensive toolset for manipulating JavaScript dates in the browser and Node.js.
In this article I'm going to show you how to get up and running with date-fns. After reading you'll be able to drop it into your projects and take advantage of its many helper methods to manipulate dates with ease. This will make code like t.getMonth() + 1, 0, 23, 59, 59
a thing of the past.
So, Why Not Just Use Moment.js?
The elephant in the room is Moment.js. This library has undoubtedly become the de-facto standard for working with dates in JavaScript. So why not use that? Why do we need another JavaScript date library?
Well, according to Sasha Koss, the creator of date-fns, Moment.js has a few inherent problems which motivated him to create date-fns. Sasha expands on what these problems are on the project's GitHub page, but in a nutshell:
- Moment.js is mutable which can cause bugs.
- It has a complex OOP API (which doubles the mutability problem).
- It has a performance overhead due to the complex API.
- Its build size is large when used with Webpack, as locale files are included as part of the bundle.
Let's contrast that with date-fns (taken from the project's homepage):
- Date-fns is immutable, always returning a new date instead of changing the one you pass in.
- It has a simple API. You always have one function that does one thing.
- It is fast. You can be sure that your users will have the best user experience.
- It is the perfect companion for Webpack. With the function-per-file style you can pick just what you need and stop bloating your project with useless functionality.
For me, the feature that makes it shine is its ease of use. When using it on a web-based project, you can just grab date-fns from a CDN, drop it into your page and profit. More about that next...
Installation
There are a variety of ways to install the library.
It's available as an npm package:
npm install date-fns --save
Or via Yarn:
yarn add date-fns
Or Bower:
bower install date-fns
Or from a CDN:
<script type="text/javascript" src="http://ift.tt/2sJFHsW"/>
If you chose this method, please note that the library is namespaced under a dateFns
object, in the same way that jQuery is namespaced under $
.
<script>
console.log(
dateFns.isToday(new Date())
);
</script>
Date-fns Basic Usage
Assuming you're using a module loader you can require only those parts you need. The following example shows you how to format a date.
const format = require('date-fns/format');
console.log(
format(new Date(2017, 6, 6), 'MM/DD/YYYY')
);
// '06/07/2017'
Want to change the locale? No problem:
Continue reading %Introduction to date-fns – a Lightweight JavaScript Date Library%
by Edwin Reynoso via SitePoint
Long Press – jQuery Plugin to Press Rare Characters Like Android/iOS
Long Press is a jQuery plugin to ease the writing of accented or rare characters as easily as on Android or iOS.
by via jQuery-Plugins.net RSS Feed