Skip to content

Documentation


Documentation / @blazetrails/activesupport / TimeZone

Class: TimeZone ​

Defined in: packages/activesupport/lib/values/time-zone.ts:355

Constructors ​

Constructor ​

new TimeZone(name, utcOffset?, tzinfo?): TimeZone

Defined in: packages/activesupport/lib/values/time-zone.ts:364

Parameters ​

ParameterTypeDefault value
namestringundefined
utcOffsetnumber | nullnull
tzinfoTimezone | nullnull

Returns ​

TimeZone

Invented Arm ​

if — PERMANENT

Invented Arm ​

create — PERMANENT

Properties ​

equals ​

equals: (this, other) => boolean = cmpEquals

Defined in: packages/activesupport/lib/values/time-zone.ts:530

Ruby Comparable#== (vendor/ruby/v3.3.11/compar.c:79 cmp_equal), the one derived operator that does NOT raise: a nil <=> is false, and an identical object is true before <=> is sent at all.

Parameters ​

ParameterType
thisComparable
otherunknown

Returns ​

boolean

No Rails Equivalent ​

PERMANENT — Ruby core Comparable cmp_equal (vendor/ruby/v3.3.11/compar.c:79).


name ​

readonly name: string

Defined in: packages/activesupport/lib/values/time-zone.ts:356


tzinfo ​

readonly tzinfo: Timezone

Defined in: packages/activesupport/lib/values/time-zone.ts:357

Accessors ​

utcOffset ​

Get Signature ​

get utcOffset(): number

Defined in: packages/activesupport/lib/values/time-zone.ts:511

Returns ​

number

Methods ​

abbr() ​

abbr(time): string

Defined in: packages/activesupport/lib/values/time-zone.ts:555

Parameters ​

ParameterType
timeTime

Returns ​

string


at() ​

at(seconds, microsecondsWithFrac?): TimeWithZone

Defined in: packages/activesupport/lib/values/time-zone.ts:501

at(*args) (time_zone.rb:378-380): Time.at(*args).utc.in_time_zone(self).

Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00 Time.at(946684800, 123456.789).nsec # => 123456789

getutc is Ruby's Time#utc on an immutable receiver (trails' ::Time has no in-place conversion), and toTime().toInstant() is the instant a TimeWithZone holds where Ruby's in_time_zone takes the ::Time itself.

Parameters ​

ParameterTypeDefault value
secondsnumber | bigint | Rationalundefined
microsecondsWithFracnumber | bigint | Rational0

Returns ​

TimeWithZone

Missing Rails Call ​

in_time_zone — PERMANENT: Time.at(*args).utc.in_time_zone(self) (time_zone.rb:379-381) round-trips through the Time core-ext to land in self; trails builds the TimeWithZone directly from the epoch instant, and in_time_zone's own TimeZone arm is that same constructor call (core-ext/date-and-time/zones.ts timeWithZone). Routing through it would close a values/time-zone -> zones -> values/time-zone module cycle (zones.ts:17 imports TimeZone from this file, and timeWithZone is not exported), which ESM cannot express — for no behavioural difference.

Missing Rails Call ​

utc — PERMANENT. Time.at(*args).utc (time_zone.rb:379-381). trails' at reaches the same instant through Time#getutc (packages/date time.ts:783) — ruby/time's own utc/getutc pair — because the ported Time is immutable and carries no in-place utc. Pre-existing: surfaced only once DateTime#utc (date_time/calculations.rb:184) was ported and utc entered the population.


compareTo() ​

compareTo(zone): number | undefined

Defined in: packages/activesupport/lib/values/time-zone.ts:520

Parameters ​

ParameterType
zoneunknown

Returns ​

number | undefined


encodeWith() ​

encodeWith(coder): void

Defined in: packages/activesupport/lib/values/time-zone.ts:568

Parameters ​

ParameterType
coderCoder

Returns ​

void


formattedOffset() ​

formattedOffset(colon?, alternateUtcString?): string

Defined in: packages/activesupport/lib/values/time-zone.ts:515

Parameters ​

ParameterTypeDefault value
colonbooleantrue
alternateUtcStringstring | nullnull

Returns ​

string


initWith() ​

initWith(coder): void

Defined in: packages/activesupport/lib/values/time-zone.ts:564

Parameters ​

ParameterType
coderCoder

Returns ​

void

Invented Arm ​

assign — PERMANENT


inspect() ​

inspect(): string

Defined in: packages/activesupport/lib/values/time-zone.ts:758

Returns ​

string


isDst() ​

isDst(time): boolean

Defined in: packages/activesupport/lib/values/time-zone.ts:559

Parameters ​

ParameterType
timeTime

Returns ​

boolean


isMatch() ​

isMatch(re): boolean

Defined in: packages/activesupport/lib/values/time-zone.ts:649

Parameters ​

ParameterType
restring | RegExp

Returns ​

boolean


iso8601() ​

iso8601(str): TimeWithZone

Defined in: packages/activesupport/lib/values/time-zone.ts:585

Parameters ​

ParameterType
strstring | null | undefined

Returns ​

TimeWithZone


local() ​

local(year, month?, day?, hour?, minute?, second?, millisecond?): TimeWithZone

Defined in: packages/activesupport/lib/values/time-zone.ts:438

Parameters ​

ParameterTypeDefault value
yearnumberundefined
monthnumber1
daynumber1
hournumber0
minutenumber0
secondnumber0
millisecondnumber0

Returns ​

TimeWithZone


localToUtc() ​

localToUtc(time, dst?): Time

Defined in: packages/activesupport/lib/values/time-zone.ts:539

Parameters ​

ParameterTypeDefault value
timeTimeundefined
dstboolean | nulltrue

Returns ​

Time


now() ​

now(): TimeWithZone

Defined in: packages/activesupport/lib/values/time-zone.ts:434

Returns ​

TimeWithZone


parse() ​

parse(str, now?): TimeWithZone | undefined

Defined in: packages/activesupport/lib/values/time-zone.ts:468

Parameters ​

ParameterType
strstring
nowTimeWithZone

Returns ​

TimeWithZone | undefined


periodForLocal() ​

periodForLocal(time, dst?): TimezonePeriod

Defined in: packages/activesupport/lib/values/time-zone.ts:547

Parameters ​

ParameterTypeDefault value
timeTime | DateTimeundefined
dstboolean | nulltrue

Returns ​

TimezonePeriod


periodForUtc() ​

periodForUtc(time): TimezonePeriod

Defined in: packages/activesupport/lib/values/time-zone.ts:543

Parameters ​

ParameterType
timeTime

Returns ​

TimezonePeriod


periodsForLocal() ​

periodsForLocal(time): TimezonePeriod[]

Defined in: packages/activesupport/lib/values/time-zone.ts:551

Parameters ​

ParameterType
timeTime | DateTime

Returns ​

TimezonePeriod[]


rfc3339() ​

rfc3339(str): TimeWithZone

Defined in: packages/activesupport/lib/values/time-zone.ts:629

Parameters ​

ParameterType
strstring

Returns ​

TimeWithZone


strptime() ​

strptime(str, format, now?): TimeWithZone | undefined

Defined in: packages/activesupport/lib/values/time-zone.ts:472

Parameters ​

ParameterType
strstring
formatstring
nowTimeWithZone

Returns ​

TimeWithZone | undefined


today() ​

today(): PlainDate

Defined in: packages/activesupport/lib/values/time-zone.ts:573

Returns ​

PlainDate


tomorrow() ​

tomorrow(): PlainDate

Defined in: packages/activesupport/lib/values/time-zone.ts:577

Returns ​

PlainDate


toString() ​

toString(): string

Defined in: packages/activesupport/lib/values/time-zone.ts:754

Returns ​

string


utcToLocal() ​

utcToLocal(time): Time

Defined in: packages/activesupport/lib/values/time-zone.ts:532

Parameters ​

ParameterType
timeTime

Returns ​

Time


yesterday() ​

yesterday(): PlainDate

Defined in: packages/activesupport/lib/values/time-zone.ts:581

Returns ​

PlainDate


all() ​

static all(): TimeZone[]

Defined in: packages/activesupport/lib/values/time-zone.ts:429

Returns ​

TimeZone[]


clear() ​

static clear(): void

Defined in: packages/activesupport/lib/values/time-zone.ts:672

Returns ​

void


countryZones() ​

static countryZones(countryCode): TimeZone[]

Defined in: packages/activesupport/lib/values/time-zone.ts:662

Parameters ​

ParameterType
countryCodestring

Returns ​

TimeZone[]


create() ​

static create<T>(this, name, utcOffset?, tzinfo?): InstanceType<T>

Defined in: packages/activesupport/lib/values/time-zone.ts:415

Type Parameters ​

Type Parameter
T extends typeof TimeZone

Parameters ​

ParameterTypeDefault value
thisTundefined
namestringundefined
utcOffsetnumber | nullnull
tzinfoTimezone | nullnull

Returns ​

InstanceType<T>


find() ​

static find(arg): TimeZone | null

Defined in: packages/activesupport/lib/values/time-zone.ts:380

Parameters ​

ParameterType
argunknown

Returns ​

TimeZone | null


findTzinfo() ​

static findTzinfo(name): Timezone

Defined in: packages/activesupport/lib/values/time-zone.ts:412

Parameters ​

ParameterType
namestring

Returns ​

Timezone


secondsToUtcOffset() ​

static secondsToUtcOffset(seconds, colon?): string

Defined in: packages/activesupport/lib/values/time-zone.ts:372

Parameters ​

ParameterTypeDefault value
secondsnumberundefined
colonbooleantrue

Returns ​

string


usZones() ​

static usZones(): TimeZone[]

Defined in: packages/activesupport/lib/values/time-zone.ts:658

Returns ​

TimeZone[]