| 1000 | * @see #in(Timezone) |
| 1001 | */ |
| 1002 | public Moment at(ZonalOffset offset) { |
| 1003 | |
| 1004 | long localSeconds = |
| 1005 | MathUtils.safeMultiply( |
| 1006 | this.date.getDaysSinceUTC() + 2 * 365, |
| 1007 | 86400); |
| 1008 | localSeconds += (this.time.getHour() * 3600); |
| 1009 | localSeconds += (this.time.getMinute() * 60); |
| 1010 | localSeconds += this.time.getSecond(); |
| 1011 | |
| 1012 | int localNanos = this.time.getNanosecond(); |
| 1013 | long posixTime = localSeconds - offset.getIntegralAmount(); |
| 1014 | int posixNanos = localNanos - offset.getFractionalAmount(); |
| 1015 | |
| 1016 | if (posixNanos < 0) { |
| 1017 | posixNanos += MRD; |
| 1018 | posixTime--; |
| 1019 | } else if (posixNanos >= MRD) { |
| 1020 | posixNanos -= MRD; |
| 1021 | posixTime++; |
| 1022 | } |
| 1023 | |
| 1024 | return Moment.of(posixTime, posixNanos, TimeScale.POSIX); |
| 1025 | |
| 1026 | } |
| 1027 | |
| 1028 | /** |
| 1029 | * <p>Combines this local timestamp with the system timezone to a global |