package com.ForgeEssentials.permission;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Set;

import com.google.common.base.Strings;

public class PermissionsList
{
	private static final String	OUTPUT_FILE	= "PermissionsList.txt";
	private File				output;

	public PermissionsList()
	{
		output = new File(ModulePermissions.permsFolder, OUTPUT_FILE);
	}

	public boolean shouldMake()
	{
		return !output.exists();
	}

	public void output(Set<String> permissions)
	{
		try
		{
			output.createNewFile();
			BufferedWriter writer = new BufferedWriter(new FileWriter(output));

			writer.write("#// ------------ PERMISSIONS LIST ------------ \\#");  writer.newLine();
			writer.write("#// ------------ Created on "+getDateString());  writer.newLine();
			writer.write("#// ------------------------------------------ \\#");  writer.newLine();
			writer.newLine();
			
			for (String perm : permissions)
			{
				writer.write(perm);
				writer.newLine();
			}
			
			writer.close();
		}
		catch (Exception e)
		{

		}
	}
	
	private String getDateString()
	{
		Calendar cal = Calendar.getInstance();
		StringBuilder builder = new StringBuilder();
		builder.append(cal.get(Calendar.MONTH)).append(' ');
		builder.append(cal.get(Calendar.DAY_OF_MONTH)).append(", ");
		builder.append(cal.get(Calendar.YEAR));
		return builder.toString();
	}

}

@@ -129,51 +129,29 @@
 ava.
-util.Calendar;%0Aimport java.util.Collections
+text.SimpleDateFormat
 ;%0Aim
@@ -169,18 +169,12 @@
 til.
-Comparator
+Date
 ;%0Aim
@@ -198,48 +198,8 @@
 t;%0A%0A
-import com.google.common.base.Strings;%0A%0A
 publ
@@ -691,39 +691,40 @@
 ST ------------ 
+%5C%5C
 %5C%5C#%22);
- 
  writer.newLine(
@@ -746,39 +746,8 @@
 ite(
-%22#// ------------ Created on %22+
 getD
@@ -757,24 +757,33 @@
 String());  
+%09%09%09%09%09%09%09%09%09
 writer.newLi
@@ -852,23 +852,24 @@
 ------- 
+%5C%5C
 %5C%5C#%22);
- 
  writer.
@@ -1099,281 +1099,142 @@
 %7B%0A%09%09
-Calendar cal = Calendar.getInstance();%0A%09%09StringBuilder builder = new StringBuilder();%0A%09%09builder.append(cal.get(Calendar.MONTH)).append(' ');%0A%09%09builder.append(cal.get(Calendar.DAY_OF_MONTH)).append(%22, %22);%0A%09%09builder.append(cal.get(Calendar.YEAR));%0A%09%09return builder.toString()
+String date = new SimpleDateFormat(%22yyyy-MM-dd HH:mm%22).format(new Date());%0A%09%09return %22#// ------------ %22 + date + %22 ------------ %5C%5C%5C%5C#%22
 ;%0A%09%7D

fixed date to ISO 8601