src/Pure/General/date.scala
changeset 69980 f2e3adfd916f
parent 65733 45b8446a8b52
child 71601 97ccf48c2f0c
equal deleted inserted replaced
69979:4744e75393d9 69980:f2e3adfd916f
    73   }
    73   }
    74 
    74 
    75 
    75 
    76   /* date operations */
    76   /* date operations */
    77 
    77 
       
    78   def timezone_utc: ZoneId = ZoneId.of("UTC")
       
    79   def timezone_berlin: ZoneId = ZoneId.of("Europe/Berlin")
       
    80 
    78   def timezone(): ZoneId = ZoneId.systemDefault
    81   def timezone(): ZoneId = ZoneId.systemDefault
    79 
    82 
    80   def now(zone: ZoneId = timezone()): Date = new Date(ZonedDateTime.now(zone))
    83   def now(zone: ZoneId = timezone()): Date = new Date(ZonedDateTime.now(zone))
    81 
    84 
    82   def instant(t: Instant, zone: ZoneId = timezone()): Date =
    85   def instant(t: Instant, zone: ZoneId = timezone()): Date =
    89 {
    92 {
    90   def midnight: Date =
    93   def midnight: Date =
    91     new Date(ZonedDateTime.of(rep.toLocalDate, LocalTime.MIDNIGHT, rep.getZone))
    94     new Date(ZonedDateTime.of(rep.toLocalDate, LocalTime.MIDNIGHT, rep.getZone))
    92 
    95 
    93   def to(zone: ZoneId): Date = new Date(rep.withZoneSameInstant(zone))
    96   def to(zone: ZoneId): Date = new Date(rep.withZoneSameInstant(zone))
    94   def to_utc: Date = to(ZoneId.of("UTC"))
       
    95 
    97 
    96   def unix_epoch: Long = rep.toEpochSecond
    98   def unix_epoch: Long = rep.toEpochSecond
    97   def instant: Instant = Instant.from(rep)
    99   def instant: Instant = Instant.from(rep)
    98   def time: Time = Time.instant(instant)
   100   def time: Time = Time.instant(instant)
    99   def timezone: ZoneId = rep.getZone
   101   def timezone: ZoneId = rep.getZone