-
-
Save asouza/219848 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Calendar | |
class Data (val data: Calendar,val ultimo:Int) { | |
import Data.Conjuncao | |
def mais(num: Int) = { new Data(data,num) } | |
def menos(num: Int) = { new Data(data,-num)} | |
def meses = { data.add(Calendar.MONTH, ultimo); this } | |
def meses(e:Conjuncao):Data = meses | |
def mês = meses | |
def mês(e:Conjuncao):Data = meses | |
def anos = { data.add(Calendar.YEAR,ultimo); this } | |
def anos(e:Conjuncao):Data = anos | |
def ano = anos | |
def ano(e:Conjuncao):Data = anos | |
def dias = { data.add(Calendar.DAY_OF_MONTH, ultimo); this } | |
def dias(e:Conjuncao):Data = dias | |
def dia = dias | |
def dia(e:Conjuncao):Data = dias | |
override def toString = "%1$Td/%1$Tm/%1$TY" format data | |
} | |
object Data { | |
class Conjuncao | |
val e = new Conjuncao | |
def Hoje = new Data(Calendar.getInstance,0) | |
def Amanhã = Hoje mais 1 dia | |
def Ontem = Hoje menos 1 dia | |
def hoje = Hoje | |
def amanhã = Amanhã | |
def ontem = Ontem | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Calendar; | |
import Data._ | |
object Teste { | |
def main(args: Array[String]) = { | |
println(Hoje mais 2 meses) | |
println(Amanhã menos 1 mês e mais 10 anos e mais 1 dia) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment