Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1019450 // howLongAgo_toMS

JavaX fragment (include)

static long howLongAgo_toMS(S s) {
  int i = indexOfSpace(s);
  S ns = replace(takeFirst(s, i), ",", "");
  if (!isInteger(ns)) ret 0;
  long n = parseLong(ns);
  s = trimSubstring(s, i);
  if (swic(s, "second")) ret n*1000;
  if (swic(s, "minute")) ret n*60000;
  if (swic(s, "hour")) ret n*60*60000;
  if (swic(s, "day")) ret n*24*60*60000;
  ret 0;
}

Author comment

Began life as a copy of #1019449

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019450
Snippet name: howLongAgo_toMS
Eternal ID of this version: #1019450/4
Text MD5: 5fc74bf423bd99d25f81b30ea3ac8b80
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-07 00:41:04
Source code size: 364 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 245 / 283
Version history: 3 change(s)
Referenced in: [show references]