package es.uv.saic.config;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;


@Configuration
@ConfigurationProperties(prefix="globals")
public class Globals {

	private String filePath = "/tmp/uploads/";
	//private String filePath = "/DATA/saic-data/files/";

	public String getFilePath() {
		return filePath;
	}
	
	public String getFileName(String npi, int curs, int informe, String apartat, int item) {
		return npi+"_"+Integer.toString(curs)+"_"+Integer.toString(informe)+"_"+apartat+Integer.toString(item);
	}
	
	public int getCurrentYear() {

		Date date = new Date();
		LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
		int month = localDate.getMonthValue();
		int year = localDate.getYear();
		
		if(month < 9) {
			return year-1;
		}
		else {
			return year;
		}
	}
	

	
}
