Sha256: cea6db0c30b4814cc74548bb4c7bf0947f894b84d5b7251c707aa22ab62abc58
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 class TwitterCldr.Calendar REDIRECT_PREFIX = "calendars.gregorian." @calendar: -> TwitterCldr.get_data().Calendar.calendar @months: (options = {}) -> root = @get_root("months", options) result = [] result[parseInt(key) - 1] = val for key, val of root result @weekdays: (options = {}) -> @get_root("days", options) @quarters: (options = {}) -> @get_root("quarters", options) @periods: (options = {}) -> @get_root("periods", options) @get_root: (key, options = {}) -> root = @calendar()[key] names_form = options["names_form"] || "wide" format = options.format || if root?["stand-alone"]?[names_form]? "stand-alone" else "format" data = root[format][names_form] # handle redirects, e.g., { "days": { "stand-alone": { "wide": "calendars.gregorian.days.format.wide" } } } if typeof data is "string" and data.indexOf(REDIRECT_PREFIX) == 0 [key, format, names_form] = data.slice(REDIRECT_PREFIX.length).split(".") @calendar()[key]?[format]?[names_form] || throw "invalid redirect #{data}" else data
Version data entries
3 entries across 3 versions & 1 rubygems