本文整理汇总了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;
}
}
示例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();
},
示例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
};
});
示例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);
}
}
示例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);
}
}
示例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
};
}));
}
示例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);
}
示例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;
}
示例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;
})