// Copyright 2001-2003, Danger, Inc.  All Rights Reserved.
// This file is subject to the Danger, Inc. Sample Code License,
// which is provided in the file SAMPLE_CODE_LICENSE.
// Copies are also available from http://developer.danger.com/

package com.danger.livejournal;

import danger.util.format.DateFormat;
import danger.util.Folder;

import java.util.Calendar;

public class JournalFolder extends Folder implements JournalResources
{
	//*	--------------------	JournalFolder

	public
	JournalFolder(int inDate)
	{
		super("");

		mDate = MakeFolderDate(inDate);
		setTitle(DateFormat.withFormat(LiveJournal.Instance().getString(kRsrc_FolderDateFormat), mDate.getTime()));
	}

	//*	--------------------	MakeFolderDate

	public static final Calendar
	MakeFolderDate(int inDate)
	{
	Calendar	date = Calendar.getInstance();
	Calendar	date2 = Calendar.getInstance();
	
		date2.setTimeInMillis(((long) inDate) * (long) 1000);
		date.setTimeInMillis((long) 0);

		date.set(Calendar.YEAR, date2.get(Calendar.YEAR));
		date.set(Calendar.MONTH, date2.get(Calendar.MONTH));
		
		return date;
	}
	
	//*	--------------------	GetDate

	public final Calendar
	GetDate()
	{
		return mDate;
	}

	//*	--------------------	onItemRemoved

	protected final void
	onItemRemoved(Object item, int index)
	{
		if (size() == 0)
			onRemoveAllItems();
	}

	//*	--------------------	onRemoveAllItems

	protected final void
	onRemoveAllItems()
	{
		getView().removeFolder(getTitle());
	}
	
	//*	--------------------------------	Class Variables
	//*	--------------------------------	Instance Variables

	private Calendar	mDate;
	
	public boolean		mIsDraft;

	//*	--------------------------------	Constants
}
