import { Injectable } from '@angular/core'; import * as tz from "moment-timezone"; import {DataFormat } from './ecpdataformat'; import { ECPTimeZoneInfo } from './ecptimezone'; /** * 国际化上下文服务 */ @Injectable() export class I18nContextService { /** * 获取当前浏览器时区 */ public getCurrentTimeZone():string { return Intl.DateTimeFormat().resolvedOptions().timeZone; } /** * 获取数据格式设置 */ public getUserDataFormat():DataFormat { return new DataFormat; //return this.dataFormat.dateFormat+" "+this.dataFormat.timeFormat; } /** * 获取当前浏览器时区偏移量 */ public getCurrentOffset():number { return (0 - new Date().getTimezoneOffset() / 60); } /** * 获取数据格式个性化设置 * @param url api */ // private getECPDataFormat(url: string): Observable { // return this.http.get(url); // } /** * 获取时区个性化设置 * @param url api */ // private getECPTimeZoneInfo(url:string):Observable{ // return this.http.get(url); // } private setcookie (name, value) { //设置名称为name,值为value的Cookie document.cookie = document.cookie + ";" + name+"="+value+";"; //即document.cookie= name+"="+value+";path=/"; 时间可以不要,但路径(path)必须要填写,因为JS的默认路径是当前页,如果不填,此cookie只在当前页面生效!~ } private getCookie(c_name) { if (document.cookie.length>0) { let c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; let c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return "" } }