diff --git a/.gitignore b/.gitignore
index 04ae7b3..776e1b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,185 +22,5 @@ bld/
[Bb]in/
[Oo]bj/
-# Visual Studio 2015 cache/options directory
-.vs/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# DNX
-project.lock.json
-artifacts/
-
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opensdf
-*.sdf
-*.cachefile
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# TODO: Comment the next line if you want to checkin your web deploy settings
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/packages/*
-# except build/, which is used as an MSBuild target.
-!**/packages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/packages/repositories.config
-
-# Windows Azure Build Output
-csx/
-*.build.csdef
-
-# Windows Store app package directory
-AppPackages/
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-[Ss]tyle[Cc]op.*
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.pfx
-*.publishsettings
-node_modules/
-orleans.codegen.cs
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-*.mdf
-*.ldf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
\ No newline at end of file
+# Library
+[Ll]ib/
\ No newline at end of file
diff --git a/blogger.toc.csproj b/blogger.toc.csproj
index e9ed07b..fbf31e0 100644
--- a/blogger.toc.csproj
+++ b/blogger.toc.csproj
@@ -87,22 +87,25 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
@@ -165,7 +168,8 @@
- $(ProjectDir)build.bat
+ $(ProjectDir)createDepsJs.bat
+$(ProjectDir)build.bat
+
@@ -16,6 +16,14 @@
No Compile Mode
printby: 'label.contentsorder',
thumbnail: {
enabled: false
+ },
+ published: {
+ enabled: true,
+ format: 'yyyy/MM/dd'
+ },
+ updated: {
+ enabled: true,
+ format: 'yyyy/MM/dd'
}
};
diff --git a/src/blogger/toc/contract.js b/src/blogger/toc/contract.js
index 654a9b5..db8a369 100644
--- a/src/blogger/toc/contract.js
+++ b/src/blogger/toc/contract.js
@@ -125,11 +125,19 @@ var contract = {
var POSTSTOC_SETTINGS = {
blogURL: '',
maxResults: Infinity,
- style: '',
orderby: '',
printby: '',
+ locale: '',
thumbnail: {
enabled: false,
noImageURL: ''
+ },
+ published: {
+ enabled: false,
+ format: ''
+ },
+ updated: {
+ enabled: false,
+ format: ''
}
};
\ No newline at end of file
diff --git a/src/blogger/toc/printer/entry.js b/src/blogger/toc/printer/entry.js
index e80f93c..6779ac8 100644
--- a/src/blogger/toc/printer/entry.js
+++ b/src/blogger/toc/printer/entry.js
@@ -1,5 +1,7 @@
goog.provide('garafu.blogger.toc.printer.Entry');
+goog.require('garafu.date.W3CDTF');
+
@@ -62,7 +64,7 @@ garafu.blogger.toc.printer.Entry.prototype.initialize = function () {
var updated = document.createElement('span');
var thumbnail = document.createElement('span');
var title = document.createElement('a');
- var img;
+ var datetime, text, img;
// Create thumbnail
if (settings.thumbnail.enabled) {
@@ -71,12 +73,20 @@ garafu.blogger.toc.printer.Entry.prototype.initialize = function () {
}
// Create published date
- published.appendChild(document.createTextNode(entry.published.$t));
- published.className = 'poststoc-published';
+ if (settings.published.enabled) {
+ datetime = garafu.date.W3CDTF.parse(entry.published.$t);
+ text = settings.published.format.format(datetime);
+ published.appendChild(document.createTextNode(text));
+ published.className = 'poststoc-published';
+ }
// Create update date
- updated.appendChild(document.createTextNode(entry.updated.$t));
- updated.className = 'poststoc-updated';
+ if (settings.updated.enabled) {
+ datetime = garafu.date.W3CDTF.parse(entry.updated.$t);
+ text = settings.updated.format.format(datetime);
+ updated.appendChild(document.createTextNode(text));
+ updated.className = 'poststoc-updated';
+ }
// Create title
title.appendChild(document.createTextNode(entry.title.$t));
@@ -87,8 +97,12 @@ garafu.blogger.toc.printer.Entry.prototype.initialize = function () {
if (settings.thumbnail.enabled) {
container.appendChild(thumbnail);
}
- container.appendChild(published);
- container.appendChild(updated);
+ if (settings.published.enabled) {
+ container.appendChild(published);
+ }
+ if (settings.updated.enabled) {
+ container.appendChild(updated);
+ }
container.appendChild(title);
container.className = 'poststoc-entry';
diff --git a/src/blogger/toc/settings.js b/src/blogger/toc/settings.js
index 09c3a85..d50e306 100644
--- a/src/blogger/toc/settings.js
+++ b/src/blogger/toc/settings.js
@@ -1,5 +1,7 @@
goog.provide('garafu.blogger.toc.Settings');
+goog.require('garafu.i18n.DateTimeFormat');
+
@@ -12,21 +14,35 @@ goog.provide('garafu.blogger.toc.Settings');
* @constructor
*/
garafu.blogger.toc.Settings = function () {
+ var defaultSettings;
// Set default settings.
- var defaultSettings = {
+ defaultSettings = {
blogURL: 'garafu.blogspot.jp',
maxResults: Infinity,
orderby: 'published',
printby: 'label',
+ locale: 'ja-jp',
thumbnail: {
enabled: false,
noImageURL: 'http://garafu.github.io/blogger.toc/release/0.0.5/noimage.png'
+ },
+ published: {
+ enabled: false,
+ format: 'yyyy/MM/dd HH:mm:ss'
+ },
+ updated: {
+ enabled: false,
+ format: 'yyyy/MM/dd HH:mm:ss'
}
};
// Apply user settings or default settings.
this.merge(this, POSTSTOC_SETTINGS, defaultSettings);
+
+ // Set date time formatter.
+ this.published.format = new garafu.i18n.DateTimeFormat(this.published.format, this.locale);
+ this.updated.format = new garafu.i18n.DateTimeFormat(this.updated.format, this.locale);
};
diff --git a/src/date/W3CDTF.js b/src/date/W3CDTF.js
index 2896201..c358ba5 100644
--- a/src/date/W3CDTF.js
+++ b/src/date/W3CDTF.js
@@ -1,5 +1,7 @@
goog.provide('garafu.date.W3CDTF');
+goog.require('garafu.string');
+
@@ -9,16 +11,31 @@ goog.provide('garafu.date.W3CDTF');
* @private
* @type {RegExp}
*/
-garafu.date.W3CDTF.regexp = new RegExp("^(\\d{4})-?(\\d{2})?-?(\\d{2})?T?(\\d{2})?:?(\\d{2})?:?(\\d{2})?(\\.\\d+)?(\\+|-|Z)?(\\d{2})?:?(\\d{2})?$");
+garafu.date.W3CDTF.regexp = /^(\d{4})-?(\d{2})?-?(\d{2})?T?(\d{2})?:?(\d{2})?:?(\d{2})?(\.\d+)?(\+|-|Z)?(\d{2})?:?(\d{2})?$/;
+/**
+* W3CDTF format type enumeration.
+*
+* @public
+*/
+garafu.date.W3CDTF.FormatType = {
+ YYYY: 1,
+ YYYYMM: 2,
+ YYYYMMDD: 3,
+ YYYYMMDD_hhmmTZD: 4,
+ YYYYMMDD_hhmmssTZD: 5,
+ YYYYMMDD_hhmmsssTZD: 6
+};
/**
* Convert W3C-DTF string to Date object.
*
+* @public
+* @static
* @param {string} text W3C-DTF string.
-* @return {Date} Date object.
+* @return {Date} Date object.
*/
garafu.date.W3CDTF.parse = function (text) {
var splitted;
@@ -61,3 +78,85 @@ garafu.date.W3CDTF.parse = function (text) {
return date;
};
+
+/**
+* Parse to string from Date object.
+*
+* @public
+* @static
+* @param {Date} date Date object.
+* @return {string} W3C-DTF format string.
+*/
+garafu.date.W3CDTF.stringify = function (date, formatType) {
+ var year = date.getUTCFullYear();
+ var month = date.getUTCMonth() + 1;
+ var day = date.getUTCDate();
+ var hour = date.getUTCHours();
+ var minute = date.getUTCMinutes();
+ var second = date.getUTCSeconds();
+ var millisecond = Math.round(date.getUTCMilliseconds() / 100.0);
+ var text = '';
+
+ // Concat string to the W3C-DTF type of YYYY-MM-DDThh:mm:ss.sTZD.
+ switch (formatType) {
+ case garafu.date.W3CDTF.FormatType.YYYY:
+ text += year;
+ break;
+ case garafu.date.W3CDTF.FormatType.YYYYMM:
+ text += year;
+ text += '-';
+ text += garafu.string.paddingNumber(month, 2);
+ break;
+ case garafu.date.W3CDTF.FormatType.YYYYMMDD:
+ text += year;
+ text += '-';
+ text += garafu.string.paddingNumber(month, 2);
+ text += '-';
+ text += garafu.string.paddingNumber(day, 2);
+ break;
+ case garafu.date.W3CDTF.FormatType.YYYYMMDD_hhmmTZD:
+ text += year;
+ text += '-';
+ text += garafu.string.paddingNumber(month, 2);
+ text += '-';
+ text += garafu.string.paddingNumber(day, 2);
+ text += 'T';
+ text += garafu.string.paddingNumber(hour, 2);
+ text += ':';
+ text += garafu.string.paddingNumber(minute, 2);
+ text += 'Z';
+ break;
+ case garafu.date.W3CDTF.FormatType.YYYYMMDD_hhmmssTZD:
+ text += year;
+ text += '-';
+ text += garafu.string.paddingNumber(month, 2);
+ text += '-';
+ text += garafu.string.paddingNumber(day, 2);
+ text += 'T';
+ text += garafu.string.paddingNumber(hour, 2);
+ text += ':';
+ text += garafu.string.paddingNumber(minute, 2);
+ text += ':';
+ text += garafu.string.paddingNumber(second, 2);
+ text += 'Z';
+ break;
+ default:
+ text += year;
+ text += '-';
+ text += garafu.string.paddingNumber(month, 2);
+ text += '-';
+ text += garafu.string.paddingNumber(day, 2);
+ text += 'T';
+ text += garafu.string.paddingNumber(hour, 2);
+ text += ':';
+ text += garafu.string.paddingNumber(minute, 2);
+ text += ':';
+ text += garafu.string.paddingNumber(second, 2);
+ text += '.';
+ text += millisecond;
+ text += 'Z'; // timezone;
+ break;
+ }
+
+ return text;
+};
diff --git a/src/deps.js b/src/deps.js
index 5ec2009..f6ec37c 100644
--- a/src/deps.js
+++ b/src/deps.js
@@ -1,18 +1,21 @@
-// This file was autogenerated by C:\Users\Owner\WorkSpace\GitHub\blogger.toc\lib\closure-library\closure\bin\build\depswriter.py.
+// This file was autogenerated by D:\Work\GitHub\blogger.toc\lib\closure-library\closure\bin\build\depswriter.py.
// Please do not edit.
goog.addDependency('../../../../src/blogger/toc/main.js', ['garafu.blogger.toc.Main'], ['garafu.blogger.toc.Settings', 'garafu.blogger.toc.printer.LabelContentsOrderPrinter', 'garafu.blogger.toc.printer.LabelNameOrderPrinter', 'garafu.blogger.toc.printer.LabelPrinter', 'garafu.blogger.toc.printer.TitlePrinter', 'garafu.blogger.toc.sorter.PublishedDateSorter', 'garafu.blogger.toc.sorter.TitleNameSorter', 'garafu.blogger.toc.sorter.UpdatedDateSorter', 'garafu.date.W3CDTF', 'garafu.dom', 'garafu.events']);
-goog.addDependency('../../../../src/blogger/toc/printer/abstractprinter.js', ['garafu.blogger.toc.printer.AbstractPrinter'], []);
-goog.addDependency('../../../../src/blogger/toc/printer/category.js', ['garafu.blogger.toc.printer.Category'], []);
-goog.addDependency('../../../../src/blogger/toc/printer/entry.js', ['garafu.blogger.toc.printer.Entry'], []);
-goog.addDependency('../../../../src/blogger/toc/printer/labelcontentsorderprinter.js', ['garafu.blogger.toc.printer.LabelContentsOrderPrinter'], ['garafu.blogger.toc.printer.LabelPrinter']);
-goog.addDependency('../../../../src/blogger/toc/printer/labelnameorderprinter.js', ['garafu.blogger.toc.printer.LabelNameOrderPrinter'], ['garafu.blogger.toc.printer.LabelPrinter']);
-goog.addDependency('../../../../src/blogger/toc/printer/labelprinter.js', ['garafu.blogger.toc.printer.LabelPrinter'], ['garafu.blogger.toc.printer.AbstractPrinter', 'garafu.blogger.toc.printer.Category', 'garafu.blogger.toc.printer.Entry']);
-goog.addDependency('../../../../src/blogger/toc/printer/titleprinter.js', ['garafu.blogger.toc.printer.TitlePrinter'], ['garafu.blogger.toc.printer.AbstractPrinter']);
-goog.addDependency('../../../../src/blogger/toc/settings.js', ['garafu.blogger.toc.Settings'], []);
-goog.addDependency('../../../../src/blogger/toc/sorter/abstractsorter.js', ['garafu.blogger.toc.sorter.AbstractSorter'], []);
-goog.addDependency('../../../../src/blogger/toc/sorter/publisheddatesorter.js', ['garafu.blogger.toc.sorter.PublishedDateSorter'], ['garafu.blogger.toc.sorter.AbstractSorter']);
-goog.addDependency('../../../../src/blogger/toc/sorter/titlenamesorter.js', ['garafu.blogger.toc.sorter.TitleNameSorter'], ['garafu.blogger.toc.sorter.AbstractSorter']);
-goog.addDependency('../../../../src/blogger/toc/sorter/updateddatesorter.js', ['garafu.blogger.toc.sorter.UpdatedDateSorter'], ['garafu.blogger.toc.sorter.AbstractSorter']);
-goog.addDependency('../../../../src/date/W3CDTF.js', ['garafu.date.W3CDTF'], []);
+goog.addDependency('../../../../src/blogger/toc/printer/AbstractPrinter.js', ['garafu.blogger.toc.printer.AbstractPrinter'], []);
+goog.addDependency('../../../../src/blogger/toc/printer/Category.js', ['garafu.blogger.toc.printer.Category'], []);
+goog.addDependency('../../../../src/blogger/toc/printer/Entry.js', ['garafu.blogger.toc.printer.Entry'], ['garafu.date.W3CDTF']);
+goog.addDependency('../../../../src/blogger/toc/printer/LabelContentsOrderPrinter.js', ['garafu.blogger.toc.printer.LabelContentsOrderPrinter'], ['garafu.blogger.toc.printer.LabelPrinter']);
+goog.addDependency('../../../../src/blogger/toc/printer/LabelNameOrderPrinter.js', ['garafu.blogger.toc.printer.LabelNameOrderPrinter'], ['garafu.blogger.toc.printer.LabelPrinter']);
+goog.addDependency('../../../../src/blogger/toc/printer/LabelPrinter.js', ['garafu.blogger.toc.printer.LabelPrinter'], ['garafu.blogger.toc.printer.AbstractPrinter', 'garafu.blogger.toc.printer.Category', 'garafu.blogger.toc.printer.Entry']);
+goog.addDependency('../../../../src/blogger/toc/printer/TitlePrinter.js', ['garafu.blogger.toc.printer.TitlePrinter'], ['garafu.blogger.toc.printer.AbstractPrinter', 'garafu.blogger.toc.printer.Entry']);
+goog.addDependency('../../../../src/blogger/toc/settings.js', ['garafu.blogger.toc.Settings'], ['garafu.i18n.DateTimeFormat']);
+goog.addDependency('../../../../src/blogger/toc/sorter/AbstractSorter.js', ['garafu.blogger.toc.sorter.AbstractSorter'], []);
+goog.addDependency('../../../../src/blogger/toc/sorter/PublishedDateSorter.js', ['garafu.blogger.toc.sorter.PublishedDateSorter'], ['garafu.blogger.toc.sorter.AbstractSorter']);
+goog.addDependency('../../../../src/blogger/toc/sorter/TitleNameSorter.js', ['garafu.blogger.toc.sorter.TitleNameSorter'], ['garafu.blogger.toc.sorter.AbstractSorter']);
+goog.addDependency('../../../../src/blogger/toc/sorter/UpdatedDateSorter.js', ['garafu.blogger.toc.sorter.UpdatedDateSorter'], ['garafu.blogger.toc.sorter.AbstractSorter']);
+goog.addDependency('../../../../src/date/W3CDTF.js', ['garafu.date.W3CDTF'], ['garafu.string']);
goog.addDependency('../../../../src/dom/dom.js', ['garafu.dom'], []);
goog.addDependency('../../../../src/events/events.js', ['garafu.events'], []);
+goog.addDependency('../../../../src/i18n/DateTimeFormat.js', ['garafu.i18n.DateTimeFormat'], ['garafu.i18n.DateTimeSymbols', 'garafu.string']);
+goog.addDependency('../../../../src/i18n/DateTimeSymbols.js', ['garafu.i18n.DateTimeSymbols'], []);
+goog.addDependency('../../../../src/string/string.js', ['garafu.string'], []);
diff --git a/src/i18n/DateTimeFormat.js b/src/i18n/DateTimeFormat.js
new file mode 100644
index 0000000..ac8c314
--- /dev/null
+++ b/src/i18n/DateTimeFormat.js
@@ -0,0 +1,426 @@
+// *************************************************************************************************
+//
+// DateTimeFormat class
+//
+// summary
+// inheritance -
+// *************************************************************************************************
+
+goog.provide('garafu.i18n.DateTimeFormat');
+
+goog.require('garafu.i18n.DateTimeSymbols');
+goog.require('garafu.string');
+
+
+
+// -------------------------------------------------------------------------------------------------
+// constructor
+// -------------------------------------------------------------------------------------------------
+
+
+/**
+* Initialize a new instance of the DateFormat class.
+*
+* @public
+* @constructor
+* @param {string|garafu.i18n.DateTimeFormat.Format} pattern The format pattern.
+* @param {string} locale Locale string.
+*
+* @class This class provide internationalize the Date format function.
+*
+* Symbol Meaning Example
+* ------ ------ ------
+* d The day of the month. Single-digit days do not have a leading zero. 3
+* dd The day of the month. Single-digit days have a leading zero. 03
+* E The abbreviated name of the day of the week, as defined in "DateTimeSymbols.SHORTWEEKDAYS". Tue
+* EE The full name of the day of the week, as defined in "DateTimeSymbols.WEEKDAYS". Tuesday
+* G The period or era. AD
+* h The hour in a 12-hour clock. Single-digit hours do not have a leading zero. 5
+* hh The hour in a 12-hour clock. Single-digit hours have a leading zero. 05
+* H The hour in a 24-hour clock. Single-digit hours do not have a leading zero. 8
+* HH The hour in a 24-hour clock. Single-digit hours have a leading zero. 08
+* m The minute. Single-digit minuites do not have a leading zero. 2
+* mm The minute. Single-digit minuites have a leading zero. 02
+* M The numeric month. 6
+* MM The numeric month. Single-digit months have a leading zero. 06
+* MMM The abbreviated name of the month, as defined in "DateTimeSymbols.SHORTMONTH" Jun
+* MMMM The full name of the month, as defined in "DateTimeSymbols.MONTHS" June
+* s The second. Single-digit months do not have a leading zero. 6
+* ss The second. Single-digit minuites have a leading zero. 06
+* t The first character in the AM/PM designator, as defined in "DateTimeSymbols.AMPMS" AM
+* yy The year without the century. 98
+* yyyy The year in four digits, including the century. 1998
+* z The time zone offset. Single-digit hours do not have a leading zero. -8
+* zz The time zone offset. Single-digit hours have a leading zero. -08
+* zzz The full time zone offset. Single-digit hours and minutes have leading zeros. -08:00
+*