Merge pull request #11659 from carlocab/time
formula: add a `time` method for use as the build time
This commit is contained in:
commit
7c2a8f64ab
@ -1551,6 +1551,18 @@ class Formula
|
|||||||
"@loader_path/../lib"
|
"@loader_path/../lib"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Creates a new `Time` object for use in the formula as the build time.
|
||||||
|
#
|
||||||
|
# @see https://www.rubydoc.info/stdlib/time/Time Time
|
||||||
|
sig { returns(Time) }
|
||||||
|
def time
|
||||||
|
if ENV["SOURCE_DATE_EPOCH"].present?
|
||||||
|
Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc
|
||||||
|
else
|
||||||
|
Time.now.utc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# an array of all core {Formula} names
|
# an array of all core {Formula} names
|
||||||
# @private
|
# @private
|
||||||
def self.core_names
|
def self.core_names
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user