當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript moment.unix函數代碼示例

本文整理匯總了TypeScript中moment.unix函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript unix函數的具體用法?TypeScript unix怎麽用?TypeScript unix使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了unix函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: findPrePostEvent

 private findPrePostEvent(event: Event) {
   if (moment.unix(event.startDate).isAfter()) {
     this.preEvent = true;
   } else if (moment.unix(event.startDate).isBefore(moment().subtract(1, 'day'))) {
     this.preEvent = false;
   } else if (moment.unix(event.startDate).isSameOrAfter(moment().subtract(1, 'day'))){
       this.preEvent = null;
   }
 }
開發者ID:marenwoodruff,項目名稱:m2,代碼行數:9,代碼來源:surveys.component.ts

示例2: RegExp

 currentw => {
   this.icon = currentw.weather.replace(new RegExp(' ', 'g'), '').toLowerCase();
   if (this.icon === 'haze' || this.icon === 'clear') this.icon = 'cloud';
   this.city = currentw.display_location.full;
   this.temp = currentw.temp_c;
   this.description = currentw.weather;
   this.feelsLike = currentw.feelslike_c;
   this.lastUpdated = moment.unix(currentw.observation_epoch).fromNow();
 },
開發者ID:bryongloden,項目名稱:rumpel,代碼行數:9,代碼來源:tile-weather.component.ts

示例3:

 .map((item) => {
     return {
         time: moment.unix(item.time).toDate(),
         temperature: Math.round(item.temperature),
         humidity: item.humidity * 100,
         precipProbability: Math.round(item.precipProbability * 100),
         precipIntensity: this._round(item.precipIntensity * (this.get("unitSystem") === "us" ? 25.4 : 1) , 2)// in/hr is a very small number so we convert to mm/h
     };
 });
開發者ID:PeterStaev,項目名稱:tangra-weather-app,代碼行數:9,代碼來源:weather-dashboard-model.ts

示例4: findPreEvent

 private findPreEvent(event:Event) {
   if (moment.unix(event.startDate).isSameOrAfter() && this.survey) {
     this.preEvent = true;
     this.preEventSurvey(this.survey);
   } else {
     this.preEvent = false;
     this.postEventSurvey(this.survey);
   }
 }
開發者ID:marenwoodruff,項目名稱:m2,代碼行數:9,代碼來源:event.component.ts

示例5: getMoment

export function getMoment(date: MomentInput, options: ExtenderOptions): Moment {
    if (options.unix) {
        return moment.unix(date as number);
    }
    else if (options.utc) {
        return moment.utc(date, options.format);
    }
    else {
        return moment(date, options.format);
    }
}
開發者ID:spatools,項目名稱:komoment,代碼行數:11,代碼來源:core.ts

示例6: loadWeatherData

    public loadWeatherData() {
        let data = this._rawWeatherData;
        let unitSystem = this.get("unitSystem");
        let currentConditionIcon: ICurrentConditionIcon = currentConditionIcons[data.currently.icon];
        let unitSymbol: IUnitSymbol = units[unitSystem];
        let currentDailyData = data.daily.data[0];
        let reverseGeocodeResult = this._rawAddressData.results[0];
        let cityComponent = reverseGeocodeResult.address_components.filter((item) => item.types.indexOf("locality") !== -1);

        this.set("city", (cityComponent.length > 0 ? cityComponent[0].long_name : reverseGeocodeResult.formatted_address));        
        this.set("currentCondition", data.currently.icon);
        if (currentConditionIcon) {
            this.set("conditionIcon1Text", currentConditionIcon.icon1.text);
            this.set("conditionIcon1Color", currentConditionIcon.icon1.color);
            this.set("conditionIcon2Text", currentConditionIcon.icon2.text);
            this.set("conditionIcon2Color", currentConditionIcon.icon2.color);
            this.set("conditionFontSize", currentConditionIcon.fontSize);
        }
        this.set("currentTemperature", Math.round(data.currently.temperature));
        this.set("currentConditionSummary", data.currently.summary);
        this.set("currentHumidity", `${Math.round(data.currently.humidity * 100)} %`);
        this.set("currentPressure", `${data.currently.pressure} ${unitSymbol.pressure}`);
        this.set("currentWindSpeed", `${data.currently.windSpeed} ${unitSymbol.windSpeed}`);
        this.set("currentWindBearing", data.currently.windBearing);
        this.set("sunriseTime", moment.unix(currentDailyData.sunriseTime).toDate());
        this.set("sunsetTime", moment.unix(currentDailyData.sunsetTime).toDate());
        this.set("moonPhaseText", this._getMoonPhaseText(currentDailyData.moonPhase));
        this.set("moonPhaseIcon", String.fromCharCode(61589 + Math.round(28 * currentDailyData.moonPhase)));
        this.set("daily", data.daily.data.map((item) => {
            return {
                day: moment.unix(item.time).toDate(),
                temperatureMin: Math.round(item.temperatureMin),
                temperatureMax: Math.round(item.temperatureMax),
                icon: conditionIcons[item.icon],
                humidity: item.humidity * 100,
                precipProbability: Math.round(item.precipProbability * 100),
                precipIntensity: this._round(item.precipIntensity * (unitSystem === "us" ? 25.4 : 1), 2) // in/hr is a very small number so we convert to mm/h
            };
        }));
    }
開發者ID:PeterStaev,項目名稱:tangra-weather-app,代碼行數:40,代碼來源:weather-dashboard-model.ts

示例7: getPostByAlias

export async function getPostByAlias(post_alias: string): Promise<Post> {
    var client: Client = await getClient();
    var resultSet: QueryResult = await client.query(`
            SELECT post.*, array_agg(post_label.post_label) AS post_labels
            FROM post
            LEFT JOIN post_label ON post_label.post_id = post.post_id 
            WHERE post.post_alias = $1
            GROUP BY post.post_id
        `, [post_alias]);

    if (resultSet.rows.length == 0) {
        throw new Error(`Post ${post_alias} not found.`);
    }

    var obj: any = resultSet.rows.pop();
    obj.post_date = moment.unix(obj.post_date).format("MMM DD, YYYY");
    return new Post(obj);
}
開發者ID:nicholas-robson,項目名稱:dkydev_webapp,代碼行數:18,代碼來源:post.ts

示例8: createTimeCell

function createTimeCell(id: number, time: number): HTMLTableDataCellElement {
    const momentTime = moment.unix(time);
    const tid = "time-cell-" + id;
    const main = document.createElement("div");
    const isADayOld = momentTime.isBefore(moment().startOf('day'));
    main.textContent = momentTime.format(isADayOld ? 'MMM DD HH:mm:ss' : 'HH:mm:ss');
    main.id = tid;

    const tooltip = document.createElement("div");
    tooltip.textContent = momentTime.format('MMM DD YYYY, HH:mm:ss [UTC]ZZ');
    tooltip.setAttribute("data-mdl-for", tid);
    tooltip.classList.add("mdl-tooltip", "mdl-tooltip--large");

    const c = document.createElement("td");
    c.appendChild(main);
    c.appendChild(tooltip);

    return c;
}
開發者ID:Kashomon,項目名稱:test-infra,代碼行數:19,代碼來源:prow.ts

示例9: if

      .find(y => {

        /** * * * * * * * * * * * * * * * * * * * * * * *
         * Temp - start (ideally would be refactored)
         * * * * * * * * * * * * * * * * * * * * * * * **/
        let thisItem;
        if (y === 'aM/PM') {
          if (item['meridian'] === 'Morning') {
            thisItem = 'AM';
          } else if (item['meridian'] === 'Evening') {
            thisItem = 'PM';
          }
        } else if (y === 'years') {
          thisItem = `${moment.unix(item['unix']).year()}`;
        } else {
          thisItem = item[y];
        }
        /** * * * * * * * * * * * * * * * * * * * * * * *
         * Temp - end
         * * * * * * * * * * * * * * * * * * * * * * * **/

        return this.flatArray(thisItem).indexOf(meta.input[y]) === -1;
      })
開發者ID:adriancarriger,項目名稱:pv-site,代碼行數:23,代碼來源:filter.pipe.ts


注:本文中的moment.unix函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。