Rethink the API to support all the new options that have grown
samsonjs opened this issue · 2 comments
alexandrnikitin commented
I want to propose the following API:
// by default
var strftime = require('../strftimeV2');
strftime('%A');
strftime('%A', date);
// localized
var strftimeLocalized = require('../strftimeV2').setLocaleTo(it_IT);
strftimeLocalized('%A');
strftimeLocalized('%A', date);
// with custom timezone
var strftimeWithCustomTimezone = require('../strftimeV2').setTimezoneTo(customTimezone);
strftimeWithCustomTimezone('%A');
strftimeWithCustomTimezone('%A', date);
// UTC based
var strftimeUTC = require('../strftimeV2').useUTC();
strftimeUTC('%A');
strftimeUTC('%A', date);
// or combined
var strftimeLocalizedUTC = require('../strftimeV2').setLocaleTo(it_IT).useUTC();
strftimeLocalizedUTC('%A');
strftimeLocalizedUTC('%A', date);
This API gives flexibility, we can add as many setup methods as we want unlike passing options via arguments. Basically you need to set up a locale or timezone just once, when you require the module. Locale/timezone as an argument to strftime looks odd, duplicated and affect performance.